Skip to content

Commit

Permalink
Fixup requestLogger end method
Browse files Browse the repository at this point in the history
This commit aims to enable returning endLogger
instead of void, thus making it possible to make calls
to the endLoggerMehod for the requestLogger end method.
Issue : WRLGS-13
  • Loading branch information
benzekrimaha committed Nov 8, 2024
1 parent 7bf334c commit bfba906
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ interface LogDictionary {
}

declare module 'werelogs' {

class EndLogger {
constructor(reqLogger: RequestLogger);
trace(msg: string, data?: LogDictionary): void;
debug(msg: string, data?: LogDictionary): void;
info(msg: string, data?: LogDictionary): void;
warn(msg: string, data?: LogDictionary): void;
error(msg: string, data?: LogDictionary): void;
fatal(msg: string, data?: LogDictionary): void;
}

export class RequestLogger {
constructor(
logger: any,
Expand All @@ -38,6 +49,7 @@ declare module 'werelogs' {
warn(msg: string, data?: LogDictionary): void;
error(msg: string, data?: LogDictionary): void;
fatal(msg: string, data?: LogDictionary): void;
end(): EndLogger;
end(msg: string, data?: LogDictionary): void;
errorEnd(msg: string, data?:LogDictionary): void;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/RequestLogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,10 @@ class RequestLogger {
* for the log entry. This is how to provide
* metadata for a specific log entry.
*
* @returns {undefined}
* @returns {EndLogger|undefined}
*/
end(msg, data) {
if (msg === undefined && data === undefined) {
if(msg===undefined && data===undefined) {
return this.endLogger;
}
return this.log(this.endLevel, msg, data, true);
Expand Down

0 comments on commit bfba906

Please sign in to comment.