trentm / node-bunyan

a simple and fast JSON logging module for node.js services
Other
7.17k stars 516 forks source link

Change time zone to local time in createLogger #716

Open WayneTvT opened 11 months ago

WayneTvT commented 11 months ago

Current I'm using the following code to create

// setup bunyan logger
const log = Bunyan.createLogger({

    name: 'app',

    streams: [
        {
            stream: process.stdout
        },
        {
            stream: new RotatingFileStream({
                level: 'trace',
                path: logPath,
                period: '1d',          // daily rotation
                totalFiles: 30,          // keep up to 10 back copies
                rotateExisting: true,  // Give ourselves a clean file when we start up, based on period
                threshold: '10m',      // Rotate log files larger than 10 megabytes
                totalSize: '20m',      // Don't keep more than 20mb of archived log files
                gzip: true             // Compress the archive log files to save space
            })
        }
    ]
});

I know that it can add "--time local" to make the time convert to local time by bunyun provided. But I'm using pkg to complie .exe to executable so I can't add "--time local". I tried to add "timeFormat: 2" into the createLogger object but it's not work. Can I add variable or something else to make the time show in local time?

Thank you