Skip to content
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

Posibility of sending meta, not as separate field, but in the same object with message and log level #209

Closed
MikeKoval opened this issue May 27, 2019 · 2 comments

Comments

@MikeKoval
Copy link

Hi!
Thank you for awesome plugin 👍

Is it possible to allow users send meta not inside separate meta field, but in the same object with message and level here https://github.com/bithavoc/express-winston/blob/master/index.js#L360?

The thing is winston documentation says const { level, message, ...meta } = info; is ok, also I tried to connect this module with https://github.com/logdna/logdna-winston/blob/master/index.js#L29 assuming meta is all other message fields except message itself and level...
Consequently I have meta.meta.res.statusCode in my logs... Visually it's ok ok, but it's not so important.

But I haven't written this issue if I haven't bumped into Depth of parsed nested fields limitation of logging service https://docs.logdna.com/docs/ingestion#section-service-limits

@yinzara
Copy link
Collaborator

yinzara commented Sep 10, 2019

This is actually a bug in how the "express-winston" library is sending log messages and has never been reported.

The "log" method on the winston Logger object is defined a "LogMethod" which has the signature:

interface LogMethod {
        (level: string, msg: string, callback: LogCallback): LoggerInstance;
        (level: string, msg: string, meta: any, callback: LogCallback): LoggerInstance;
        (level: string, msg: string, ...meta: any[]): LoggerInstance;
    }

However, the express-winston library calls winston using the syntax:
logger.log({level, message: msg, meta})
when it should be:
logger.log(level, msg, meta)

Doing this will correctly insert the information in the correct location in the logs. PR forthcoming however this will dramatically change the output from the library and I have a feeling will not be accepted unless we have a major version upgrade.

@yinzara
Copy link
Collaborator

yinzara commented Mar 1, 2020

This is now fixed with express-winston 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants