Giter Site home page Giter Site logo

express-winston-logger's Introduction

Express Winston Logger with stats

Setup to log requests as well as custom message at different log levels to console as well as to file with stats.

Getting started

$ git clone [email protected]:arvindr21/express-winston-logger.git
$ cd express-winston-logger
$ npm install
$ node app.js

visit http://localhost:3000

Sample log file can be found at express-winston-logger/log/application-*.log. log folder is excluded from git. Sample output

{"message":"Server is running on http://localhost:3000","level":"info"}
{"level":"info","message":"GET / 200 0ms","meta":{}}
{"level":"info","message":"GET / 200 1ms","meta":{}}
{"level":"info","message":"GET / 200 0ms","meta":{}}
{"level":"info","message":"GET / 200 0ms","meta":{}}
{"level":"info","message":"GET / 200 0ms","meta":{}}
{"level":"info","message":"GET / 200 0ms","meta":{}}
{"level":"info","message":"GET / 200 1ms","meta":{}}
{"level":"info","message":"GET / 200 0ms","meta":{}}
{"level":"info","message":"GET /fail 404 2ms","meta":{}}
{"level":"info","message":"GET /fail 404 1ms","meta":{}}
{"level":"info","message":"GET /stats 200 2ms","meta":{}}

View stats

You can visit http://localhost:3000/stats to view request response stats. Sample output

{
    "uptime": 12217,
    "statusCodes":
    {
        "200": 8,
        "404": 2
    },
    "uuid": "7211ec59-1e29-4edc-94c0-4d6b560b618b",
    "pid": 19508,
    "totalTime": 4.548214,
    "averageTime": 0.4548214,
    "count": 10,
    "endpointStats":
    {
        "GET /":
        {
            "totalTime": 1.695694,
            "averageTime": 0.21196175,
            "count": 8,
            "statusCodes":
            {
                "200": 8
            }
        },
        "GET /fail":
        {
            "totalTime": 2.8525199999999997,
            "averageTime": 1.4262599999999999,
            "count": 2,
            "statusCodes":
            {
                "404": 2
            }
        }
    }
}

express-winston-logger's People

Contributors

arvindr21 avatar

Watchers

James Cloos avatar  avatar

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.