zlogjs-express-logger

0.0.14 • Public • Published

zlogjs-express-logger

log express request, response, locally or on a remote server.

Join the chat at https://gitter.im/Emallates/zlogjs-express-logger Version Build Status
ISSUES FORKS STARS Downloads
License

DESCRIPTION

zlogjs-express-logger is a plugin for zlogjs-adapter to log native http server requests and responses.

Table of Contents

  1. Installation
  2. Configuration
  3. Log
  4. Issues and Suggestions
  5. License

Installation

npm install zlogjs-express-logger --save

Configuration

As this logger is a plugin of zlogjs-adapter, you need to install that first. To log locally just put the value of mode local otherwise remote.

var config = {
    collections:{
        adapter:{
            host:'host', port:'port',
            adapter:require('zlogjs-adapter'), plugin:'zlogjs-express-logger',
            appId:'appid', apiKey:'apikey',
            mode:'remote'
        }
    }
};

Skip

var config = {
    collections:{
        adapter:{
            host:'host', port:'port',
            adapter:require('zlogjs-adapter'), plugin:'zlogjs-express-logger',
            appId:'appid', apiKey:'apikey',
            mode:'remote',
            SKIP:{
              '/api1':true, 
              '/api2':{CODE:204},
              '/api4':{METHOD:'get'},
              '/api6':{CODE:{'>':200,'<':300}}
            },
            SKIP_CODE:400
        }
    }
};
 

Tags

var config = {
    collections:{
        adapter:{
        host:'host', port:'port',
        adapter:require('zlogjs-adapter'), plugin:'zlogjs-express-logger',
        appId:'appid', apiKey:'apikey',
        mode:'remote',
            TAGS:{
                "/api/a":"tag1",
                "/api/b":"tag1:tvalue",
                "/api/c":["tag1:tvalue","tag2:tvalue"],
                "/api/d":["tag1","tag2"],
                "/api/e":{"tag1":"tvalue","tag2":"tvalue"},
                "splitter":":"
            }
        }
    }
};

Log

To start using this logger you need to construct it from zlogjs-adapter and enoa-client. Then you need to include it as a middleware of the express application.

Global

var logger = require('enoa-client')(config).adapter.logger;
express_app.use(logger);

Specific

you need to add an additional header x-man-zlogjs to the request object if you manually log something

//req.headers['x-man-zlogjs'] = true;
logger(req, res, CallbackFn);

Issues and Suggestions

This is the first version of zlogjs-express-logger, so we are looking forward to make this logger perfect. if there is any issue or you want to add new feature to the logger please feel free to raise it.

License

MIT © 2016 Emallates

Package Sidebar

Install

npm i zlogjs-express-logger

Weekly Downloads

12

Version

0.0.14

License

MIT

Last publish

Collaborators

  • emallates