-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Created the class `ProcessSummary` (based on the existing one) at the generic library to allow the capture of logs alongside processes like integrations and schedulers services. The goal is to allow the capture of a set of logs to allow them to be logged at the same time for convenience. For instance, the below logs are better interpreted if read altogether. This effort does not have the intention of removing the `QueueProcessSummary` but it improves the logs one step further.
- Loading branch information
1 parent
598073f
commit 12d9f30
Showing
7 changed files
with
291 additions
and
40 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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from "./logger-utils"; | ||
export * from "./logger.module"; | ||
export * from "./logger.service"; | ||
export * from "./process-summary"; |
23 changes: 22 additions & 1 deletion
23
sources/packages/backend/libs/utilities/src/logger/logger.service.ts
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 |
---|---|---|
@@ -1,7 +1,28 @@ | ||
import { Injectable, ConsoleLogger, Scope } from "@nestjs/common"; | ||
import { LogLevels, ProcessSummary } from "./process-summary"; | ||
|
||
/** | ||
* Common log across entire solution. | ||
*/ | ||
@Injectable({ scope: Scope.TRANSIENT }) | ||
export class LoggerService extends ConsoleLogger {} | ||
export class LoggerService extends ConsoleLogger { | ||
/** | ||
* Writes all the log entries. | ||
* @param processSummary process summary logs. | ||
*/ | ||
logProcessSummary(processSummary: ProcessSummary): void { | ||
for (const logEntry of processSummary.flattenLogs()) { | ||
switch (logEntry.level) { | ||
case LogLevels.Error: | ||
this.error(logEntry.message); | ||
break; | ||
case LogLevels.Warn: | ||
this.warn(logEntry.message); | ||
break; | ||
default: | ||
this.log(logEntry.message); | ||
break; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.