-
Notifications
You must be signed in to change notification settings - Fork 50
Closed
Labels
api: loggingIssues related to the googleapis/nodejs-logging-winston API.Issues related to the googleapis/nodejs-logging-winston API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.
Description
Environment details
- OS: MacOS
- Node.js version: 10 LTS
- npm version:
@google-cloud/logging-winston
version: 3.0.6winston
3.2.1
Steps to reproduce
Winston 3 now has a mechanism to wait for logs to flush described here: https://github.com/winstonjs/winston/blob/master/UPGRADE-3.0.md#winstonlogger
winston.Logger.log and level-specific methods (.info, .error, etc) no longer accepts a callback. The vast majority of use cases for this feature was folks awaiting all logging to complete, not just a single logging message.
Since upgrading, I am unable to get the logs to flush before the process exits (via signal or normal termination).
const winston = require("winston")
const { LoggingWinston } = require("@google-cloud/logging-winston")
const logger = winston.createLogger({
exitOnError: false,
level: "info",
transports: [
new winston.transports.Console({
handleExceptions: false
}),
new LoggingWinston({
keyfileName:
"/Users/jamesholcomb/keys/2e645b0b8d27.json",
projectId: "my-proj"
})
]
})
logger.emitErrs = false
logger.info("started")
process.on("SIGINT", () => {
logger.info("Ctrl-C pressed")
logger.on("finish", () => process.exit(0))
logger.end()
})
process.openStdin()
Output error:
{"message":"started","level":"info"}
^C{"message":"Ctrl-C pressed","level":"info"}
events.js:174
throw er; // Unhandled 'error' event
^
Error: write after end
at writeAfterEnd (/Users/jamesholcomb/gcp-test/node_modules/winston/node_modules/readable-stream/lib/_stream_writable.js:261:12)
at DerivedLogger.Writable.write (/Users/jamesholcomb/gcp-test/node_modules/winston/node_modules/readable-stream/lib/_stream_writable.js:305:21)
at DerivedLogger.info (/Users/jamesholcomb/gcp-test/node_modules/winston/lib/winston/create-logger.js:81:14)
at process.on (/Users/jamesholcomb/gcp-test/index.js:42:10)
at process.emit (events.js:198:13)
Emitted 'error' event at:
at errorOrDestroy (/Users/jamesholcomb/gcp-test/node_modules/winston/node_modules/readable-stream/lib/internal/streams/destroy.js:98:101)
at writeAfterEnd (/Users/jamesholcomb/gcp-test/node_modules/winston/node_modules/readable-stream/lib/_stream_writable.js:263:3)
at DerivedLogger.Writable.write (/Users/jamesholcomb/gcp-test/node_modules/winston/node_modules/readable-stream/lib/_stream_writable.js:305:21)
[... lines matching original stack trace ...]
at process.emit (events.js:198:13)
If I comment out the LoggingWinston transport setup, there is no error.
Scrandre
Metadata
Metadata
Assignees
Labels
api: loggingIssues related to the googleapis/nodejs-logging-winston API.Issues related to the googleapis/nodejs-logging-winston API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.