Skip to content

Commit 38d9d03

Browse files
chore: update logic
1 parent 4a9f464 commit 38d9d03

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

packages/collector/src/logger.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ exports.init = function init(userConfig = {}) {
123123
const pinoOpts = {
124124
...parentLogger.levels,
125125
level: parentLogger.level || 'info',
126-
base: parentLogger.bindings()
126+
base: parentLogger.bindings(),
127+
timestamp: () => `,"time":"${new Date().toISOString()}"`
127128
};
128129

129130
// CASE: Either its the customers pino instance (and probably a different pino installation/version)
@@ -134,18 +135,14 @@ exports.init = function init(userConfig = {}) {
134135
const symbols = Object.getOwnPropertySymbols(instance);
135136

136137
// CASE: We copy any settings from the pino instance such as custom formats.
137-
if (symbols && Array.isArray(symbols)) {
138+
if (userConfig.logger && symbols && Array.isArray(symbols)) {
138139
// If there's a custom timestamp function from the userConfig logger , we'll respect that
139140
const timeSym = symbols.find(sym => String(sym) === 'Symbol(pino.time)');
140141
// @ts-ignore
141142
const timestampFn = instance[timeSym];
142143

143-
// Only use the user's timestamp function if it's from a user-provided logger
144-
if (timestampFn && userConfig.logger) {
144+
if (timestampFn) {
145145
pinoOpts.timestamp = timestampFn;
146-
} else if (!pinoOpts.timestamp) {
147-
// If no timestamp function is set yet, fallback to ISO format
148-
pinoOpts.timestamp = () => `,"time":"${new Date().toISOString()}"`;
149146
}
150147

151148
const formattersSym = symbols.find(sym => String(sym) === 'Symbol(pino.formatters)');

0 commit comments

Comments
 (0)