Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/stefanoschrs/agathias

Another Logging Library for NodeJS
https://github.com/stefanoschrs/agathias

bunyan express logging morgan nodejs standard

Last synced: about 2 months ago
JSON representation

Another Logging Library for NodeJS

Awesome Lists containing this project

README

        


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
```javascript
const logger = require('agathias')

logger.info('Hello')
logger.debug('World')
```

2. Simple Case w/ config
```javascript
const logger = require('agathias')
const config = {
appName: 'Simple App'
}

logger
.init(config)
.then(() => logger.debug('Hello'))
.catch(console.error)
```

3. File Case
```javascript
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)
```

4. Middleware Case (ExpressJS)
```javascript
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)
```

5. Group logs by 'children'
```javascript
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