Skip to content

Commit

Permalink
feat(logger): introduce loglevel trace (aws-powertools#1589)
Browse files Browse the repository at this point in the history
  • Loading branch information
timo92 committed Aug 8, 2024
1 parent b064408 commit 4fff41a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/logger/src/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ class Logger extends Utility implements LoggerInterface {
* The levels are in ascending order from the most verbose to the least verbose (no logs).
*/
private readonly logLevelThresholds: LogLevelThresholds = {
TRACE: 6,
DEBUG: 8,
INFO: 12,
WARN: 16,
Expand Down Expand Up @@ -636,6 +637,17 @@ class Logger extends Utility implements LoggerInterface {
return this.getLogEvent();
}

/**
* It prints a log item with level TRACE.
*
* @param {LogItemMessage} input
* @param {Error | LogAttributes | string} extraInput
* @returns {void}
*/
public trace(input: LogItemMessage, ...extraInput: LogItemExtraInput): void {
this.processLogItem(6, input, extraInput);
}

/**
* It prints a log item with level WARN.
*
Expand Down
1 change: 1 addition & 0 deletions packages/logger/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const LogJsonIndent = {
} as const;

const LogLevel = {
TRACE: 'TRACE',
DEBUG: 'DEBUG',
INFO: 'INFO',
WARN: 'WARN',
Expand Down
1 change: 1 addition & 0 deletions packages/logger/src/types/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ type LoggerInterface = {
setLogLevel(logLevel: LogLevel): void;
setPersistentLogAttributes(attributes?: LogAttributes): void;
shouldLogEvent(overwriteValue?: boolean): boolean;
trace(input: LogItemMessage, ...extraInput: LogItemExtraInput): void;
warn(input: LogItemMessage, ...extraInput: LogItemExtraInput): void;
};

Expand Down

0 comments on commit 4fff41a

Please sign in to comment.