*Add debug code to track log messages and store then in memory to be accessed over rpc
This commit is contained in:
parent
5e4f45180e
commit
7c873db91b
|
@ -75,4 +75,22 @@ prefix.apply(log, {
|
|||
},
|
||||
});
|
||||
|
||||
const logFactory = log.methodFactory;
|
||||
|
||||
let messageLog: string[] = [];
|
||||
|
||||
log.methodFactory = function (methodName, logLevel, loggerName) {
|
||||
var rawMethod = logFactory(methodName, logLevel, loggerName);
|
||||
|
||||
return function (...messages) {
|
||||
messageLog = messages.concat(messages);
|
||||
rawMethod(...messages);
|
||||
};
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
log.getLogs = function (): string[] {
|
||||
return messageLog;
|
||||
};
|
||||
|
||||
export default config;
|
||||
|
|
|
@ -177,6 +177,14 @@ const plugin: Plugin = {
|
|||
return [...getRpcServer().cache.dhtCache.connectedTo];
|
||||
},
|
||||
});
|
||||
|
||||
api.registerMethod("get_logs", {
|
||||
cacheable: false,
|
||||
async handler(): Promise<string[]> {
|
||||
// @ts-ignore
|
||||
return api.logger.getLogs();
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue