nodejs-logging
nodejs-logging copied to clipboard
Logging a circularly dependent object does nothing.
Environment details
- OS: Mac OS 15
- Node.js version: 22
- npm version: 10.8.3
-
@google-cloud/loggingversion: 11.2 (via logging-winston 6.0.0)
Steps to reproduce
- log something having a circular reference
- see nothing in the logs
The below will using a plain console transport log an error. With the LoggingWinston transport on the other hand the error will be silent.
import { LoggingWinston } from "@google-cloud/logging-winston";
import winston from 'winston';
const logSomething = (transport) => {
const logger = winston.createLogger({
transports: [transport],
format: winston.format.combine(
winston.format.errors({ stack: true }),
winston.format.json()),
})
logger.info('hello logging world');
const error = {
message: 'hello error world',
};
//it's usally indirect but this will do
error['cause'] = error;
logger.error('here a circular problem', error);
logger.info('bye');
}
logSomething(new winston.transports.Console());
logSomething(new LoggingWinston({
redirectToStdout: true,
useMessageField: false,
projectId: process.env.gcpProjectId,
}));
This is extra problematic due to a common error AxiosError having a circular dependency and hence such failures are omitted from production logs.