-
Notifications
You must be signed in to change notification settings - Fork 529
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
(1.2.0) add dev+ format #19
Conversation
@c0d3rman please, do not bump versions in pull requests. ever. |
This pull request is extremely rude, dictating our release schedule and version numbers. "dev" is only only intended for using on your console for local development, not for when random people are connection, which is why the IP is not in "dev" format. If you want your own special format, you can define it yourself: var express = require('express')
var morgan = require('morgan')
morgan.format('dev+', function(tokens, req, res){
var color = 32; // green
var status = res.statusCode;
if (status >= 500) color = 31; // red
else if (status >= 400) color = 33; // yellow
else if (status >= 300) color = 36; // cyan
var fn = compile('\x1b[90m:remote-addr \x1b[32m:method \x1b[35m:url \x1b[/' + color + 'm:status \x1b[97m:response-time ms\x1b[0m');
return fn(tokens, req, res);
})
var app = express()
app.use(morgan('dev+')) |
Sorry! I didn't mean to offend. |
ah, yea. you'll want to concat strings anyway, like the old version of the "dev" format did. compile is slower, i just switched dev to use it to make it more readable. |
Is compile something we should be making public?
Maybe you should have, but about the compile function. I hope you don't feel too offed by this. |
I guess |
That's perfectly fine, and you're free to define your own formats here. It just doesn't fit into something we're going to add to this module's default list (which is just samples/standard formats that like Apache uses).
No, it's just an internal utility and not very extendable, which is why it is not exposed for people to use. It makes typing out the long string-concatenating things in core easy and non-redundant. If we exposed it, it would need to actually be full-featured and tested. @c0d3rman noticed already that you cannot use |
Anyway, the real issue here, i.m.o., is that you cannot specify a format as a string that has conditional coloring. I'm working to add that feature now, then you can specify your custom colored format as a string instead of a function. |
Okay. Thanks for your help! |
Added dev+ logging format (dev with more information)
I used dev for easy logging in my server. I decided it needed to give IP addresses, etc.
Please add this as an optional way to get more information during development.
Will not be useful to everyone, but it definitely can't hurt.