forked from cerc-io/laconic-console
Incremental
This commit is contained in:
parent
20e152f6e3
commit
44fd5a0830
@ -16,7 +16,10 @@ const oldLines = [];
|
|||||||
|
|
||||||
const SignalLog = () => {
|
const SignalLog = () => {
|
||||||
const { config } = useContext(ConsoleContext);
|
const { config } = useContext(ConsoleContext);
|
||||||
const data = useQueryStatusReducer(useQuery(SIGNAL_LOG, { pollInterval: config.api.intervalLog }));
|
const data = useQueryStatusReducer(useQuery(SIGNAL_LOG, {
|
||||||
|
pollInterval: config.api.intervalLog,
|
||||||
|
variables: { first: oldLines.length === 0 }
|
||||||
|
}));
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -28,7 +31,7 @@ const SignalLog = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Log log={oldLines.slice(0)} />
|
<Log log={oldLines.slice(0)}/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
# Copyright 2020 DxOS.org
|
# Copyright 2020 DxOS.org
|
||||||
#
|
#
|
||||||
|
|
||||||
query {
|
query ($incremental: Boolean) {
|
||||||
signal_log {
|
signal_log(incremental: $incremental) {
|
||||||
timestamp
|
timestamp
|
||||||
json
|
json
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
# Copyright 2020 DxOS.org
|
# Copyright 2020 DxOS.org
|
||||||
#
|
#
|
||||||
|
|
||||||
query {
|
query($incremental: Boolean) {
|
||||||
wns_log {
|
wns_log(incremental: $incremental) {
|
||||||
timestamp
|
timestamp
|
||||||
json
|
json
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"build": {
|
"build": {
|
||||||
"name": "@dxos/console-app",
|
"name": "@dxos/console-app",
|
||||||
"buildDate": "2020-06-10T22:08:16.919Z",
|
"buildDate": "2020-06-10T22:43:33.469Z",
|
||||||
"version": "1.0.0-beta.0"
|
"version": "1.0.0-beta.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,16 +13,16 @@ type JSONResult {
|
|||||||
#
|
#
|
||||||
|
|
||||||
type Query {
|
type Query {
|
||||||
app_log: JSONResult!
|
app_log(incremental: Boolean): JSONResult!
|
||||||
app_status: JSONResult!
|
app_status: JSONResult!
|
||||||
ipfs_log: JSONResult!
|
ipfs_log(incremental: Boolean): JSONResult!
|
||||||
ipfs_status: JSONResult!
|
ipfs_status: JSONResult!
|
||||||
ipfs_swarm_log: JSONResult!
|
ipfs_swarm_log(incremental: Boolean): JSONResult!
|
||||||
ipfs_swarm_status: JSONResult!
|
ipfs_swarm_status: JSONResult!
|
||||||
signal_log: JSONResult!
|
signal_log(incremental: Boolean): JSONResult!
|
||||||
signal_status: JSONResult!
|
signal_status: JSONResult!
|
||||||
system_status: JSONResult!
|
system_status: JSONResult!
|
||||||
wns_log: JSONResult!
|
wns_log(incremental: Boolean): JSONResult!
|
||||||
wns_status: JSONResult!
|
wns_status: JSONResult!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ class LogCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const _caches = new Map();
|
const _caches = new Map();
|
||||||
|
|
||||||
const getLogCache = (name) => {
|
const getLogCache = (name) => {
|
||||||
let cache = _caches.get(name);
|
let cache = _caches.get(name);
|
||||||
if (!cache) {
|
if (!cache) {
|
||||||
@ -38,48 +39,50 @@ const getLogCache = (name) => {
|
|||||||
return cache;
|
return cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
const getLogs = async (name, lines = 100) => {
|
const getLogs = async (name, incremental = false, lines = 100) => {
|
||||||
const command = 'wire';
|
const command = 'wire';
|
||||||
const args = ['service', 'logs', '--lines', lines, name];
|
const args = ['service', 'logs', '--lines', lines, name];
|
||||||
|
|
||||||
const child = spawnSync(command, args, { encoding: 'utf8' });
|
const child = spawnSync(command, args, { encoding: 'utf8' });
|
||||||
const logLines = child.stdout.split(/\n/);
|
const logLines = child.stdout.split(/\n/);
|
||||||
const cache = getLogCache(name);
|
const cache = getLogCache(name);
|
||||||
return cache.append(logLines);
|
const added = cache.append(logLines);
|
||||||
|
|
||||||
|
return incremental ? added : Array.from(cache.buffer);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const logResolvers = {
|
export const logResolvers = {
|
||||||
Query: {
|
Query: {
|
||||||
wns_log: async () => {
|
wns_log: async (_, { incremental }) => {
|
||||||
const logs = await getLogs('wns-lite');
|
const logs = await getLogs('wns-lite', incremental);
|
||||||
return {
|
return {
|
||||||
timestamp: new Date().toUTCString(),
|
timestamp: new Date().toUTCString(),
|
||||||
json: JSON.stringify(logs)
|
json: JSON.stringify(logs)
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
signal_log: async () => {
|
signal_log: async (_, { incremental }) => {
|
||||||
const logs = await getLogs('signal');
|
const logs = await getLogs('signal', incremental);
|
||||||
return {
|
return {
|
||||||
timestamp: new Date().toUTCString(),
|
timestamp: new Date().toUTCString(),
|
||||||
json: JSON.stringify(logs)
|
json: JSON.stringify(logs)
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
ipfs_log: async () => {
|
ipfs_log: async (_, { incremental }) => {
|
||||||
const logs = await getLogs('ipfs');
|
const logs = await getLogs('ipfs', incremental);
|
||||||
return {
|
return {
|
||||||
timestamp: new Date().toUTCString(),
|
timestamp: new Date().toUTCString(),
|
||||||
json: JSON.stringify(logs)
|
json: JSON.stringify(logs)
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
ipfs_swarm_log: async () => {
|
ipfs_swarm_log: async (_, { incremental }) => {
|
||||||
const logs = await getLogs('ipfs');
|
const logs = await getLogs('ipfs-swarm-connect', incremental);
|
||||||
return {
|
return {
|
||||||
timestamp: new Date().toUTCString(),
|
timestamp: new Date().toUTCString(),
|
||||||
json: JSON.stringify(logs)
|
json: JSON.stringify(logs)
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
app_log: async () => {
|
app_log: async (_, { incremental }) => {
|
||||||
const logs = await getLogs('ipfs');
|
const logs = await getLogs('app', incremental);
|
||||||
return {
|
return {
|
||||||
timestamp: new Date().toUTCString(),
|
timestamp: new Date().toUTCString(),
|
||||||
json: JSON.stringify(logs)
|
json: JSON.stringify(logs)
|
||||||
|
Loading…
Reference in New Issue
Block a user