-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add interface for logger, add logger factories
- Loading branch information
1 parent
22b3f1e
commit 4bfc5f7
Showing
7 changed files
with
69 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export interface Logger { | ||
debug(message: string, obj?: object): void; | ||
info(message: string, obj?: object): void; | ||
warning(message: string, obj?: object): void; | ||
error(message: string, obj?: object): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from "./pino"; | ||
|
||
export { RealLogger } from "./logger"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Logger as PinoLogger } from "pino"; | ||
|
||
|
||
export class RealLogger { | ||
constructor(protected readonly pinoLogger: PinoLogger) {} | ||
|
||
debug(message: string, obj?: object): void { | ||
this.pinoLogger.debug(obj, message) | ||
} | ||
|
||
info(message: string, obj?: object): void { | ||
this.pinoLogger.info(obj, message) | ||
} | ||
|
||
warning(message: string, obj?: object): void { | ||
this.pinoLogger.warn(obj, message) | ||
} | ||
|
||
error(message: string, obj?: object): void { | ||
this.pinoLogger.error(obj,message) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Logger as PinoLogger, pino } from "pino"; | ||
|
||
import { OperationId } from "src/application"; | ||
|
||
|
||
export function pinoRootLoggerFactory(): PinoLogger { | ||
return pino() | ||
} | ||
|
||
|
||
export function pinoLoggerFactory( | ||
rootPinoLogger: PinoLogger, | ||
operationId: OperationId, | ||
): PinoLogger { | ||
return rootPinoLogger.child({"operation_id": operationId}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters