-
Notifications
You must be signed in to change notification settings - Fork 50
Open
Labels
api: loggingIssues related to the googleapis/nodejs-logging-winston API.Issues related to the googleapis/nodejs-logging-winston API.priority: p3Desirable enhancement or fix. May not be included in next release.Desirable enhancement or 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
My goal is that each time I call logger.error
with whatever content an entry in Error Reporting is created.
However, that doesn't work. Only some errors make it to the Error Reporting, some others appear well in the logs, but not in Error Reporting.
I've read the "Error Reporting" paragraph in the docs. But, still, I don't get it.
- How do you pass an
Error
object? Tried likeObject.assign(info, { message: new Error(info.message) });
- but without luck so far. - What is the expected content of
service
andversion
? I've set a random string inservice
and leftversion
aside. - What else am I missing?
Here's my complete config:
import winston from 'winston';
import { LoggingWinston } from '@google-cloud/logging-winston';
import compact from 'lodash/compact';
const loggingWinston = new LoggingWinston({ serviceContext: { service: `some-random-string-here` } });
const formatErrorsAsError = winston.format((info) => {
if (info.level === 'error') {
Object.assign(info, { message: new Error(info.message) });
}
return info;
});
const logger = winston.createLogger({
level: vars.env === 'development' ? 'debug' : 'info',
format: winston.format.combine(
formatErrorsAsError(),
vars.env === 'development'
? winston.format.colorize()
: winston.format.uncolorize(),
winston.format.splat(),
winston.format.printf(({ level, message }) => `${level}: ${message}`),
),
transports: compact([
new winston.transports.Console({
stderrLevels: ['error'],
}),
vars.env !== 'development' && loggingWinston,
]),
});
deriegle and jamesholcomb
Metadata
Metadata
Assignees
Labels
api: loggingIssues related to the googleapis/nodejs-logging-winston API.Issues related to the googleapis/nodejs-logging-winston API.priority: p3Desirable enhancement or fix. May not be included in next release.Desirable enhancement or 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.