-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Respecting winston formatting #540
Comments
Hi, I'll add a +1 vote for a fix for this, it would really help my projects out. |
Note: In order for Google Cloud Logging API to understand the log level correctly, we need to have something that changes log structure format inside this library, like this: const GoogleCloudLoggingFormatter = winston.format((info, opts={}) => {
info['severity'] = info['level'].toUpperCase();
return info;
});
const logger = winston.createLogger({
level: 'info',
format: winston.format.combine(
winston.format.timestamp(),
GoogleCloudLoggingFormatter(), // This must be before winston.fomrat.json()
winston.format.json(),
),
transports: [
new winston.transports.Console({ level: 'info' })
]
}); |
Still under investigation. Yoshi may take another look. |
I took a glance of this code base and it seems this library is not passing format options to transports. On the other hand, The tricky part is that this libraries
I guess the todos are:
|
I made another investigation, and this requires a kind of interface change around how we treat messages passed to Cloud Logging library. In |
As of now, the implementation expects the logs to be structured logs and not considering them to be in other format. We decided to add the logic to send them as textPayload when the users specifies custom formats. |
I did further investigations on setting logs in TL;DR: we need fundamental change if we want to route custom format logs to Background
If we would like to embed the custom format log to Compromised work around is to fill custom format log into the |
Yeah, I think that putting formatted log entry into message field of jsonPayload would be a decent compromise. |
This problem was attempted to be fixed before in #548 and based on comments seems winston library does not have a unified way to return formatted message. The code sample
Given a fact that we don't have a way to see if formatting was provided for Opened issue #125 on logfrom. |
Closing this issue since the fix for #125 will resolve this issue without any change in this library |
@losalex I just came across this issue. Perhaps this should be in your documentation? It may have led me to try using Bunyan. Also, is there any workaround you can think of here? If Winston never addresses your bug, this will be an issue for users for a while. |
@lgtm2 , thanks for reaching out! |
This logger ignores format settings.
In the above example, console logs presents proper format defined in 'format' field, but google-cloud/logging-winston doesn't.
The text was updated successfully, but these errors were encountered: