Comments (2)
Thank you for your suggestion and I notice that connect logger is totally changed. I agree to add responseTime in the logger, but that responseTime will be only an indicator for the performance as it may not accurate: the logger middleware don't like the connect one, I don't know where the user will add it to. Also the responseTime will not show up in default format.
And you are right the levels should be changeable and user agent also could be a option.
But I'll still to the current level as default:
< 400 -> info 2xx and 3xx are acceptable for browser, it's normal status
< 500 -> warning 4xx means bad client request, it's not the responsibility of the server side, so it should be warning
>= 500 -> error 5xx means server error, but I don't think it should be fatal as express don't exit due this error. It only affect one request
I'm thinking adding 'levelFn' to the options, so user can change the level according to the statusCode (IMO, the level should be seen in statusCode for any http services, you can't have a 200 request/response but want a error level). The function will be like:
function (statusCode) {
if (...) return 'warning';
if (...) return 'error';
return 'info';
}
And another option will 'parseUA', which default goes true.
Is that meet you needs? listen to your ideas, thx
Villa
from express-bunyan-logger.
Hello,
- yes the response time is not quite accurate, since it starts when the hook is called and ends with the hook , but if you put the app.use at the top most level it will handle it pretty good.
- one more thing, I would add a flag which when set to true logs the start of the request and like now the end; this is pretty useful when you debug your own actions since you see in the logs when the request arrived and what you did before answering the request
levelFN
is great your defaults as default is absolutely ok; just assure that fatal is also possible as an level
-parseUA
is ok too
keep on this great work
Ognian
from express-bunyan-logger.
Related Issues (20)
- Error handling middleware that is registered after bunyanLogger.errorLogger() will not be invoked
- Exclude request and response body HOT 2
- Optionally do not pass meta object to bunyan HOT 3
- Add specific field to all logs HOT 2
- Update to bunyan 1.0.0 release
- Deprecation warning with express HOT 2
- Exclude for a stream? HOT 1
- `process.hrtime()` vs `Date.now()`? HOT 3
- Add support to use the already configured bunyan logger instance HOT 2
- Log without brackets HOT 2
- Can't install with iojs 3 HOT 1
- includesFn in doc but not there HOT 6
- Don't mutate options
- exclude by route HOT 2
- Missing Documentation for `opts.logger` option
- Obfuscation potentially mutates req/res data HOT 1
- Clearer error message if you use the library incorrectly
- deprecation errors with nodejs v12 HOT 8
- 200 status is incorrectly logged when connection is aborted
- Vulnerability in express-bunyan-logger-1.3.3.tgz (Root Library) > useragent-2.3.0.tgz (Vulnerable Library).
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from express-bunyan-logger.