1.0.4 • Published 4 months ago

chrona v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

chrona

Simple HTTP request logger middleware for express.js inspired by koa-logger, written in typescript.

npm.io

Installation

This is a Node.js module available through the npm registry. Installation is done using the npm install command:

$ npm install chrona

API

var chrona = require('chrona')

app.use(chrona())

Make sure to add chrona to first in middleware chain.

chrona(format, options)

Create a new chrona middleware function using the given format and options. By default, it creates with default format and default options value. The format argument is a string of predefined token names(see below for token names).

Predefined token names.

Using a predefined format string

app.use(chrona(":incoming :method :url :status :response-time :content-length :user-agent :http-version"))

options

chroma accepts options argument as a function or an object. Right now chroma has only one option call transporter which can be provided either by passing function or an object with transporter key. Transporter is for change chrona's default transporter(where to show log messages) which is console.log.

Use Custom Transporter

// If you want to go with default format string, then just pass
// empty string or null
app.use(chrona(null, function(str, args) => {
    // pass str and args to your own transporter like winston etc.
}))
1.0.4

4 months ago

1.0.3

4 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago