agathias

0.0.4 • Public • Published

Agathias

Travis Build Standard - JavaScript Style Guide MIT License

Another Logging Library


Easy to use logging

Install

npm i --save agathias

Usage

  1. Simple Case
const logger = require('agathias')
 
logger.info('Hello')
logger.debug('World')
  1. Simple Case w/ config
const logger = require('agathias')
const config = {
  appName: 'Simple App'
}
 
logger
  .init(config)
  .then(() => logger.debug('Hello'))
  .catch(console.error)
  1. File Case
const logger = require('agathias')
const config = {
  file: true,
  fileName: 'my-app-file-case.log',
  logDir: '/tmp', // Path must have an absolute value, you can use __dirname
}
 
logger
  .init(config)
  .then(() => logger.debug('Hello'))
  .catch(console.error)
  1. Middleware Case (ExpressJS)
const http = require('http')
const express = require('express')
const logger = require('agathias')
const app = express()
 
logger
  .init({
    logDir: '/tmp'
  })
  .then(() => {
    app.use(logger.getMiddleware(true))
    app.get('/', (req, res) => res.send('Hello World'))
 
    let server = app.listen(process.env.PORT || 5000)
    http.get('http://0.0.0.0:5000/no', (res) => {
      let data = ''
      res.on('data', (chunk) => data += chunk)
      res.on('end', () => server.close())
    })
  })
  .catch(console.error)
  1. Group logs by 'children'
const logger = require('agathias')
 
logger
  .init()
  .then(() => {
    logger.debug('Hello')
    const childNode1 = logger.getChild('testing')
    childNode1.debug('Hello')
    const childNode2 = logger.getChild('this is real')
    childNode2.debug('World')
  })
  .catch(console.error)

Features

  • Seamless integration with log rotate
  • Optional express logging

Package Sidebar

Install

npm i agathias

Weekly Downloads

2

Version

0.0.4

License

MIT

Last publish

Collaborators

  • stefanoschrs