@@ -24,6 +24,7 @@ import type {
24
24
LogItemMessage ,
25
25
LoggerInterface ,
26
26
PowertoolsLogData ,
27
+ UnformattedAttributes ,
27
28
} from './types/Logger.js' ;
28
29
29
30
/**
@@ -1080,12 +1081,19 @@ class Logger extends Utility implements LoggerInterface {
1080
1081
*
1081
1082
* @private
1082
1083
* @param {LogFormatterInterface } logFormatter
1084
+ * @param {Array<keyof UnformattedAttributes> } logRecordOrder
1083
1085
* @returns {void }
1084
1086
*/
1085
- private setLogFormatter ( logFormatter ?: LogFormatterInterface ) : void {
1087
+ private setLogFormatter (
1088
+ logFormatter ?: LogFormatterInterface ,
1089
+ logRecordOrder ?: Array < keyof UnformattedAttributes >
1090
+ ) : void {
1086
1091
this . logFormatter =
1087
1092
logFormatter ??
1088
- new PowertoolsLogFormatter ( { envVarsService : this . getEnvVarsService ( ) } ) ;
1093
+ new PowertoolsLogFormatter ( {
1094
+ envVarsService : this . getEnvVarsService ( ) ,
1095
+ logRecordOrder,
1096
+ } ) ;
1089
1097
}
1090
1098
1091
1099
/**
@@ -1119,6 +1127,7 @@ class Logger extends Utility implements LoggerInterface {
1119
1127
persistentKeys,
1120
1128
persistentLogAttributes, // deprecated in favor of persistentKeys
1121
1129
environment,
1130
+ logRecordOrder,
1122
1131
} = options ;
1123
1132
1124
1133
if ( persistentLogAttributes && persistentKeys ) {
@@ -1140,7 +1149,7 @@ class Logger extends Utility implements LoggerInterface {
1140
1149
this . setInitialSampleRate ( sampleRateValue ) ;
1141
1150
1142
1151
// configurations that affect how logs are printed
1143
- this . setLogFormatter ( logFormatter ) ;
1152
+ this . setLogFormatter ( logFormatter , logRecordOrder ) ;
1144
1153
this . setConsole ( ) ;
1145
1154
this . setLogIndentation ( ) ;
1146
1155
0 commit comments