Skip to content

Latest commit

 

History

History
31 lines (22 loc) · 705 Bytes

README.md

File metadata and controls

31 lines (22 loc) · 705 Bytes

fun-component/logger

Log all lifecycle events. Using nanologger.

Usage

Access the nanologger instance under ctx.log.

const html = require('nanohtml')
const component = require('fun-component')

var hello = component(function hello (ctx, title) {
  return html`
    <div>
      Hello ${title}!
    </div>
  `
})

// enable logging during development
if (process.env.NODE_ENV === 'development') {
  hello.use(require('fun-component/logger')())
}

API

logger([opts])

Create a middleware that adds an instance of nanologger to the ctx.log property. The opts are forwarded to nanologger.