Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/stefanoschrs/agathias
- Owner: stefanoschrs
- License: mit
- Created: 2017-01-25T10:44:53.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-11T02:49:22.000Z (about 2 years ago)
- Last Synced: 2024-04-15T11:39:02.956Z (9 months ago)
- Topics: bunyan, express, logging, morgan, nodejs, standard
- Language: JavaScript
- Homepage:
- Size: 669 KB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
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