GCP logging winston LoggingWinston severity
If you want to control severity at LoggingWinston.
https://stackoverflow.com/questions/58055551/structured-logs-in-google-cloud-run-not-being-parsed-using-winston-for-logging
const winston = require('winston');
const useFormat = winston.format.combine(
winston.format((info, opts) => {
let level = info.level.toUpperCase();
if(level === 'VERBOSE') {
level = 'DEBUG';
}
info['severity'] = level;
delete info.level;
return info;
})(),
winston.format.json());
const { LoggingWinston } = require('@google-cloud/logging-winston');
const loggingWinston = new LoggingWinston();
const logger = winston.createLogger({
level: 'debug',
format: useFormat,
transports: [
new winston.transports.Console(),
loggingWinston
]
});
訂閱:
文章 (Atom)