1+ import { Console } from 'node:console' ;
2+ import { randomInt } from 'node:crypto' ;
13import { Utility } from '@aws-lambda-powertools/commons' ;
24import type { HandlerMethodDecorator } from '@aws-lambda-powertools/commons/types' ;
35import type { Context , Handler } from 'aws-lambda' ;
46import merge from 'lodash.merge' ;
5- import { Console } from 'node:console' ;
6- import { randomInt } from 'node:crypto' ;
77import { EnvironmentVariablesService } from './config/EnvironmentVariablesService.js' ;
88import { LogJsonIndent } from './constants.js' ;
9- import { LogItem } from './formatter/LogItem.js' ;
9+ import type { LogItem } from './formatter/LogItem.js' ;
1010import { PowertoolsLogFormatter } from './formatter/PowertoolsLogFormatter.js' ;
1111import type { ConfigServiceInterface } from './types/ConfigServiceInterface.js' ;
1212import type {
1313 Environment ,
1414 LogAttributes ,
15+ LogFormatterInterface ,
1516 LogLevel ,
1617 LogLevelThresholds ,
17- LogFormatterInterface ,
1818} from './types/Log.js' ;
1919import type {
20- LogFunction ,
2120 ConstructorOptions ,
21+ CustomJsonReplacerFn ,
2222 InjectLambdaContextOptions ,
23+ LogFunction ,
2324 LogItemExtraInput ,
2425 LogItemMessage ,
2526 LoggerInterface ,
2627 PowertoolsLogData ,
27- CustomJsonReplacerFn ,
2828} from './types/Logger.js' ;
2929
3030/**
@@ -442,10 +442,7 @@ class Logger extends Utility implements LoggerInterface {
442442 options ?: InjectLambdaContextOptions
443443 ) : HandlerMethodDecorator {
444444 return ( _target , _propertyKey , descriptor ) => {
445- /**
446- * The descriptor.value is the method this decorator decorates, it cannot be undefined.
447- */
448- /* eslint-disable @typescript-eslint/no-non-null-assertion */
445+ // biome-ignore lint/style/noNonNullAssertion: The descriptor.value is the method this decorator decorates, it cannot be undefined.
449446 const originalMethod = descriptor . value ! ;
450447
451448 // eslint-disable-next-line @typescript-eslint/no-this-alias
@@ -463,8 +460,6 @@ class Logger extends Utility implements LoggerInterface {
463460 let result : unknown ;
464461 try {
465462 result = await originalMethod . apply ( this , [ event , context , callback ] ) ;
466- } catch ( error ) {
467- throw error ;
468463 } finally {
469464 if ( options ?. clearState || options ?. resetKeys ) loggerRef . resetKeys ( ) ;
470465 }
@@ -697,22 +692,24 @@ class Logger extends Utility implements LoggerInterface {
697692 const references = new WeakSet ( ) ;
698693
699694 return ( key , value ) => {
700- if ( this . #jsonReplacerFn) value = this . #jsonReplacerFn?.( key , value ) ;
695+ let replacedValue = value ;
696+ if ( this . #jsonReplacerFn)
697+ replacedValue = this . #jsonReplacerFn?.( key , replacedValue ) ;
701698
702- if ( value instanceof Error ) {
703- value = this . getLogFormatter ( ) . formatError ( value ) ;
699+ if ( replacedValue instanceof Error ) {
700+ replacedValue = this . getLogFormatter ( ) . formatError ( replacedValue ) ;
704701 }
705- if ( typeof value === 'bigint' ) {
706- return value . toString ( ) ;
702+ if ( typeof replacedValue === 'bigint' ) {
703+ return replacedValue . toString ( ) ;
707704 }
708- if ( typeof value === 'object' && value !== null ) {
709- if ( references . has ( value ) ) {
705+ if ( typeof replacedValue === 'object' && replacedValue !== null ) {
706+ if ( references . has ( replacedValue ) ) {
710707 return ;
711708 }
712- references . add ( value ) ;
709+ references . add ( replacedValue ) ;
713710 }
714711
715- return value ;
712+ return replacedValue ;
716713 } ;
717714 }
718715
@@ -855,10 +852,10 @@ class Logger extends Utility implements LoggerInterface {
855852 * @returns - The name of the log level
856853 */
857854 private getLogLevelNameFromNumber ( logLevel : number ) : Uppercase < LogLevel > {
858- let found ;
855+ let found : Uppercase < LogLevel > | undefined ;
859856 for ( const [ key , value ] of Object . entries ( this . logLevelThresholds ) ) {
860857 if ( value === logLevel ) {
861- found = key ;
858+ found = key as Uppercase < LogLevel > ;
862859 break ;
863860 }
864861 }
0 commit comments