https://github.com/mhio/node-logger
Node logging with pino+debug
https://github.com/mhio/node-logger
debug logging pino
Last synced: 2 months ago
JSON representation
Node logging with pino+debug
- Host: GitHub
- URL: https://github.com/mhio/node-logger
- Owner: mhio
- Created: 2020-04-03T02:31:35.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2023-01-05T18:21:26.000Z (over 2 years ago)
- Last Synced: 2025-03-18T04:58:08.363Z (2 months ago)
- Topics: debug, logging, pino
- Language: JavaScript
- Homepage:
- Size: 381 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
@mhio/node-logger
-----------Node logging with [`pino`](https://github.com/pinojs/pino) and [`debug`](https://github.com/visionmedia/debug).
```
yarn add @mhio/node-logger
```Setup a base logger in `./logger.js`
```
import { MhioLogger } from '@mhio/node-logger'
export const Logger = new MhioLogger('your:log:prefix')
export default Logger
// or
const { MhioLogger } = require('@mhio/node-logger')
const Logger = new MhioLogger('your:log:prefix')
module.exports = Logger
```Then in each module
```
import Logger from './logger'
const Logger = require('./logger')const { logger, debug } = Logger.ns('myModule')
// Pino
logger.info({ msg: 'test', data: {} })// DEBUG="your:prefix" node app.js
debug('test', { ok: true })
```## Changelog
0.3.0 Upgrade to pino 6, remove debug as it's a runtime injection
0.2.0 Remove `{namespace}` duplication from loggers metadata
## Related
[`@mhio/node-logger-http`](https://github.com/mhio/node-logger-http)