-
-
Notifications
You must be signed in to change notification settings - Fork 536
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
:status color when not dev too. #186
Comments
You can reimplement that morgan.token(`status`, (req, res) => {
const status = (typeof res.headersSent !== `boolean`
? Boolean(res._header)
: res.headersSent)
? res.statusCode
: undefined
// get status color
const color =
status >= 500
? 31 // red
: status >= 400
? 33 // yellow
: status >= 300
? 36 // cyan
: status >= 200
? 32 // green
: 0 // no color
return `\x1b[${color}m${status}\x1b[0m`
}) Copied from Line 183 in 12a48c5
|
@dotconnor thanks I replaced the I preferred to use an other name for the token instead of using an existing one. I think it's safer. |
Any reason not to make this colouring default for |
@vasanthv I'm quite new to morgan, so maybe I'm not right but I guess this is because Trying to use
|
There's now a PR open for this #227
This is exactly right. The colors add a lot of extra text around the actual status code which would make it very difficult to parse in a file. |
I really like the colored status but when I use not dev but custom string, :status is not colored. hope this is colored too because it's cool.
Always appreciate your works.
The text was updated successfully, but these errors were encountered: