kenperkins / winston-papertrail

Papertrail transport for Winston
MIT License
203 stars 94 forks source link

logFormat, message incorrect formated #81

Open kzinevych opened 6 years ago

kzinevych commented 6 years ago

Guy can someone tell me. Had update the winston-papertrail to version 1.0.5 (winston version 3.0.0), and saw interesting thing. 2nd parameter 'message' that came in logFormat, formated like this, example: 'Some message { message: 'Some message', level: 'info' }' Should it be like this, or not? If yes, how to work with it? After investigation I found in file /lib/winston-papertrail.js, line:325 (var output = msg;) That set this duplication msg.

`var output = msg;

// If we don't have a string for the message,
// lets transform it before moving on
if (typeof(output) !== 'string') {
    output = util.inspect(output, false, self.depth, self.colorize);
}

if (meta) {
    if (typeof meta !== 'object') {
        output += ' ' + meta;
    }
    else if (meta) {
        if (this.inlineMeta) {
            output += ' ' + util.inspect(meta, false, self.depth, self.colorize).replace(/[\n\t]\s*/gm, " ");
        }
        else {
            output += '\n' + util.inspect(meta, false, self.depth, self.colorize);
        }
    }
}

this.sendMessage(this.hostname, this.program, level, output, callback);`

How logs should looks like? How work with colorize? It doesn't work for me. Maybe someone can share best practice.

Would be apriciate for any help.

shailesh-kanzariya commented 3 years ago

I am also facing similar issue with winston 3.x and winston-papertrail 1.0.5. Papertrail sends logs as message = message-string + stringified JSON object. This reduces log readability and creates distraction. If I downgrade to winston 2.2.0 then winston-papertrail 1.0.5 send proper logs without stringified JSON object.

Please share updates on this issue.