Skip to content

A koa logger middleware and want to look for a girlfriend...

License

Notifications You must be signed in to change notification settings

bluedapp/koa-base-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

koa-base-logger

Logging middleware for koa

Installation

https://npmjs.org/package/koa-base-logger

$ npm install koa-base-logger

Usage

const Koa = require('koa')
const Router = require('koa-router')
const baselogger = require('koa-base-logger')

const app = new Koa()
const router = new Router()

app.use(baselogger({
  appName: 'app',
  fileName: 'file',
}))

router.get('/', (ctx, next) => {
  ctx.logger.info({ notice: 'I lose what i love most...' })
  ctx.logger.warn({ notice: 'I also want to look for a girlfriend...' })
  try {
    alert(err)
  } catch (err) {
    ctx.logger.error(err, { notice: 'Who is my love match?' })
  }

  ctx.body = 'Hello World'
})

app.use(router.routes())

app.listen(0258)

Options

// defaults options
{
  appName: 'app',
  automate: true,
  dailyRotateFile: {
    datePattern: 'YYYY-MM-DD',
    maxFiles: '30d',
    maxSize: '100m',
  },
  fileName: 'app',
  recordBody: false,
  root: path.join(path.dirname(__dirname), '../logs'),
}

License

MIT License

About

A koa logger middleware and want to look for a girlfriend...

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published