You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently we are passing around method arguments such as requestIdPrefix, mode, methodName, etc., which are used only for logging and are cluttering the whole code base with unneeded arguments in interfaces.
Solution
Add a new facade class which wraps pino's Logger, we can call it LoggerService (similar to the one in hedera-local-node), which will wrap all methods of Logger (trace, debug, info,warn,error). It will also contain the state of the current requests that are being made to the relay. E.g.:
classLoggerService{private_requestId: string;// other data which is used only for logssetrequestId(requestId: string): void{this._requestId=requestId;}getrequestIdPrefix(): string{if(!this._requestId){return'';}return`[Request ID: ${this._requestId}]`;}constructor(privatereadonlylogger: Logger){}info(msg: string, ...args: any[]): void{constformattedMsg=msg ? `${this.requestIdPrefix}${msg}` : msg;this.logger.info(formattedMsg,args);}// rest of the methods...}
These methods will format the message with additional context from the stored state it holds inside. In this way, we can remove any redundant arguments from all classes in the relay, and only update the state of the Logger facade class, in a middleware of the KoaApp:
Problem
Currently we are passing around method arguments such as
requestIdPrefix
,mode
,methodName
, etc., which are used only for logging and are cluttering the whole code base with unneeded arguments in interfaces.Solution
Add a new facade class which wraps pino's
Logger
, we can call itLoggerService
(similar to the one inhedera-local-node
), which will wrap all methods ofLogger
(trace
,debug
,info
,warn
,error
). It will also contain the state of the current requests that are being made to the relay. E.g.:These methods will format the message with additional context from the stored state it holds inside. In this way, we can remove any redundant arguments from all classes in the relay, and only update the state of the
Logger
facade class, in a middleware of theKoaApp
:The text was updated successfully, but these errors were encountered: