bithavoc / express-winston

express.js middleware for winstonjs
https://www.npmjs.com/package/express-winston
MIT License
798 stars 186 forks source link

expressFormat logging formatting error #80

Closed jacobbridges closed 8 years ago

jacobbridges commented 9 years ago

I am using this awesome logger in my express app. But when I start my express server and hit an endpoint, the debug info which is showing up in the console looks like this:

GET /test 200 7msGET /test 200 7ms
PUT /test 200 12ms
PUT /test 200 11msGET /test 200 8ms

See the error? It looks like every GET request log is not prepended with a newline character. I looked into the source code and tried to edit line 246 of express-winston/index.js

// before
var msg = chalk.grey(req.method + " " + req.url || req.url)

// after
var msg = chalk.grey("\n" + req.method + " " + req.url || req.url)

After that edit, my output looked like this:


GET /test 200 7ms
GET /test 200 7ms

PUT /test 200 12ms

PUT /test 200 11ms
GET /test 200 8ms

So yeah.. somewhere in the code the GET request is not getting a newline.


I am using version 0.3.1 of express-winston, and this is the configuration I am using for the logger:

expressWinston.logger({
        transports: [
          new winston.transports.Console({
            json: false,
            colorize: true,
            showLevel: false
          })
        ],
        expressFormat: true,
        meta: false
floatingLomas commented 9 years ago

Crappy. I'll have a look.

...Or you can make a pull request. :P

jacobbridges commented 9 years ago

Yeah I tried editing it lol. But now the PUT request logs have two newlines...so I'm not sure what's going on. I'll give it another look.

floatingLomas commented 9 years ago

I'm pretty sure this isn't an express-winston thing - we don't put newlines in there anywhere.

What OS are you using?

jacobbridges commented 9 years ago

I've tried it on Ubuntu Trusty and OS X 10.9.5. Both have the same result.

floatingLomas commented 9 years ago

Are you doing anything else with winston? Any other modules, any customizations, or anything?

floatingLomas commented 9 years ago

Did you ever resolve this, or figure out what it was?

rosston commented 8 years ago

Closed due to inactivity. Doesn't seem to be a problem in express-winston itself.