Skip to content

synchrolog/synchrolog-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Synchrolog

Installation

$ npm install synchrolog-node

Usage

Format the log messages the same way as Morgan https://github.com/expressjs/morgan#morganformat-options

const synchrologConfig = require('synchrolog-node/config');
const synchrologLogger = require('synchrolog-node/logger');
const synchrologError = require('synchrolog-node/error');


// Initialize your express app, and pass the app to the synchrolog module
var app = express();

// ADD synchrologConfig and synchrologLogger after initializing the express app
synchrologConfig('YOUR_API_KEY');
synchrologLogger(app, 'combined');

// you can also use customized logging formats
// synchrologLogger(app, function (tokens, req, res) {
//   return [
//     tokens.method(req, res),
//     tokens.url(req, res),
//     tokens.status(req, res),
//     tokens['response-time'](req, res), 'ms'
//   ].join(' ')
// });

// synchrologLogger(app, ':remote-addr - :remote-user [:date[clf]] ":method :url');

app.get('/', function handler(req, res) {
  throw new Error("Hi! I'm an error!");
});

// ADD synchrologError right after the routes
app.use(synchrologError);

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/synchrolog/synchrolog-node. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The package is available as open source under the terms of the MIT License.

About

Synchrolog library for Node.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors