You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cannot format timestamp using winston.format.timestamp.
What version of Winston presents the issue?
v3.10.0
What version of Node are you using?
v16.13.2
If this worked in a previous version of Winston, which was it?
No response
Minimum Working Example
importwinstonfrom'winston';importmongodbfrom'mongodb';// Requiring `winston-mongodb` will expose winston.transports.MongoDB`import'winston-mongodb';constMongoClient=mongodb.MongoClient;constlog=winston.createLogger({level: 'info',transports: [newwinston.transports.Console({format: winston.format.simple(),level: 'info'})],format: winston.format.combine(winston.format.timestamp({format: 'YYYY-MM-DD HH:mm:ss',}),),});// logging to console so farlog.info('Connecting to database...');consturl="mongodb://localhost:27017/mydb";constclient=newMongoClient(url);awaitclient.connect();consttransportOptions={db: awaitPromise.resolve(client),collection: 'log',};log.add(newwinston.transports.MongoDB(transportOptions));// following entry should appear in log collection and will contain// metadata JSON-property containing url fieldlog.info('Connected to database.',{url});
Additional information
winston-mongodb: v5.1.1
As a workaround, it's possible to store a custom timestamp under .metadata, like this:
constlog=winston.createLogger({level: 'info',transports: [newwinston.transports.Console({format: winston.format.simple(),level: 'info'})],format: winston.format.combine(winston.format(info=>{info.metadata={myTs: newDate().toLocaleDateString()};// or any other formatreturninfo;})(),),});
The text was updated successfully, but these errors were encountered:
🔎 Search Terms
timezone, timestamp
The problem
Cannot format timestamp using
winston.format.timestamp
.What version of Winston presents the issue?
v3.10.0
What version of Node are you using?
v16.13.2
If this worked in a previous version of Winston, which was it?
No response
Minimum Working Example
Additional information
winston-mongodb: v5.1.1
As a workaround, it's possible to store a custom timestamp under
.metadata
, like this:The text was updated successfully, but these errors were encountered: