Giter VIP home page Giter VIP logo

Comments (2)

villadora avatar villadora commented on May 31, 2024

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.

Ognian avatar Ognian commented on May 31, 2024

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
  • levelFNis great your defaults as default is absolutely ok; just assure that fatal is also possible as an level
    -parseUAis ok too

keep on this great work
Ognian

from express-bunyan-logger.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.