More logging.
This commit is contained in:
parent
5965c53696
commit
0fb12ec30f
@ -12,7 +12,7 @@ app:
|
||||
|
||||
api:
|
||||
path: '/api'
|
||||
port: 4000
|
||||
port: 4004
|
||||
intervalLog: 5000
|
||||
pollInterval: 10000
|
||||
|
||||
|
@ -106,6 +106,9 @@ const Log = ({ log = [] }) => {
|
||||
);
|
||||
};
|
||||
|
||||
// TODO(telackey): Why do these display in reverse?
|
||||
log.reverse();
|
||||
|
||||
return (
|
||||
<div className={classes.root}>
|
||||
<div className={classes.log}>
|
||||
|
@ -11,6 +11,9 @@ import { ConsoleContext, useQueryStatusReducer } from '../../../hooks';
|
||||
|
||||
import Log from '../../../components/Log';
|
||||
|
||||
const MAX_LINES = 1000;
|
||||
const oldLines = [];
|
||||
|
||||
const SignalLog = () => {
|
||||
const { config } = useContext(ConsoleContext);
|
||||
const data = useQueryStatusReducer(useQuery(SIGNAL_LOG, { pollInterval: config.api.intervalLog }));
|
||||
@ -18,8 +21,14 @@ const SignalLog = () => {
|
||||
return null;
|
||||
}
|
||||
|
||||
const newLines = JSON.parse(data.signal_log.json);
|
||||
oldLines.push(...newLines);
|
||||
if (oldLines.length > MAX_LINES) {
|
||||
oldLines.splice(0, oldLines.length - MAX_LINES);
|
||||
}
|
||||
|
||||
return (
|
||||
<Log log={data.signal_log.log} />
|
||||
<Log log={oldLines.slice(0)} />
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -11,16 +11,24 @@ import { ConsoleContext, useQueryStatusReducer } from '../../../hooks';
|
||||
|
||||
import Log from '../../../components/Log';
|
||||
|
||||
const MAX_LINES = 1000;
|
||||
const oldLines = [];
|
||||
|
||||
const WNSLog = () => {
|
||||
const { config } = useContext(ConsoleContext);
|
||||
const data = useQueryStatusReducer(useQuery(WNS_LOG, { pollInterval: config.api.intervalLog }));
|
||||
console.error(data);
|
||||
if (!data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const newLines = JSON.parse(data.wns_log.json);
|
||||
oldLines.push(...newLines);
|
||||
if (oldLines.length > MAX_LINES) {
|
||||
oldLines.splice(0, oldLines.length - MAX_LINES);
|
||||
}
|
||||
|
||||
return (
|
||||
<Log log={JSON.parse(data.wns_log.json)} />
|
||||
<Log log={oldLines.slice(0)} />
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -3,8 +3,8 @@
|
||||
#
|
||||
|
||||
query {
|
||||
signal_log @client {
|
||||
signal_log {
|
||||
timestamp
|
||||
log
|
||||
json
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"build": {
|
||||
"name": "@dxos/console-app",
|
||||
"buildDate": "2020-06-10T20:28:40.010Z",
|
||||
"buildDate": "2020-06-10T22:08:16.919Z",
|
||||
"version": "1.0.0-beta.0"
|
||||
}
|
||||
}
|
||||
|
@ -13,15 +13,17 @@ type JSONResult {
|
||||
#
|
||||
|
||||
type Query {
|
||||
app_swarm_log: JSONResult!
|
||||
app_log: JSONResult!
|
||||
app_status: JSONResult!
|
||||
ipfs_log: JSONResult!
|
||||
ipfs_status: JSONResult!
|
||||
ipfs_swarm_log: JSONResult!
|
||||
ipfs_swarm_status: JSONResult!
|
||||
signal_log: JSONResult!
|
||||
signal_status: JSONResult!
|
||||
signal_swarm_log: JSONResult!
|
||||
system_status: JSONResult!
|
||||
wns_status: JSONResult!
|
||||
wns_log: JSONResult!
|
||||
wns_status: JSONResult!
|
||||
}
|
||||
|
||||
schema {
|
||||
|
@ -2,11 +2,7 @@
|
||||
// Copyright 2020 DxOS.org
|
||||
//
|
||||
|
||||
import moment from 'moment';
|
||||
import pick from 'lodash.pick';
|
||||
import os from 'os';
|
||||
import si from 'systeminformation';
|
||||
import { spawnSync } from "child_process";
|
||||
import { spawnSync } from 'child_process';
|
||||
|
||||
class LogCache {
|
||||
constructor(maxLines = 500) {
|
||||
@ -60,6 +56,34 @@ export const logResolvers = {
|
||||
timestamp: new Date().toUTCString(),
|
||||
json: JSON.stringify(logs)
|
||||
};
|
||||
},
|
||||
signal_log: async () => {
|
||||
const logs = await getLogs('signal');
|
||||
return {
|
||||
timestamp: new Date().toUTCString(),
|
||||
json: JSON.stringify(logs)
|
||||
};
|
||||
},
|
||||
ipfs_log: async () => {
|
||||
const logs = await getLogs('ipfs');
|
||||
return {
|
||||
timestamp: new Date().toUTCString(),
|
||||
json: JSON.stringify(logs)
|
||||
};
|
||||
},
|
||||
ipfs_swarm_log: async () => {
|
||||
const logs = await getLogs('ipfs');
|
||||
return {
|
||||
timestamp: new Date().toUTCString(),
|
||||
json: JSON.stringify(logs)
|
||||
};
|
||||
},
|
||||
app_log: async () => {
|
||||
const logs = await getLogs('ipfs');
|
||||
return {
|
||||
timestamp: new Date().toUTCString(),
|
||||
json: JSON.stringify(logs)
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user