*Add debug code to track log messages and store then in memory to be accessed over rpc

This commit is contained in:
Derrick Hammer 2022-12-16 08:05:16 -05:00
parent 5e4f45180e
commit 7c873db91b
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 26 additions and 0 deletions

View File

@ -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;

View File

@ -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();
},
});
},
};