0.4.2 • Published 5 years ago

noderus v0.4.2

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

noderus@0.4.0 docs /Users/Nick/work/noderus documentation build index.js -f md --github

Table of Contents

setStandardFields

lib/standardFields.js:17-24

Sets up the default set of fields to be logged with every message. Call this before using the logger.

Parameters

  • service string The name of parent service
  • version string The version of the service

Examples

const { name, version } = require('./package.json')

setStandardFields(name, version)

trace

lib/basic.js:48-48

Forwards to console.log. Combines the fields provided with the standard fields.

Parameters

  • msg string The message itself
  • fields object? The collection of additional fields to log with the message

info

lib/basic.js:57-57

Forwards to console.log. Combines the fields provided with the standard fields.

Parameters

  • msg string The message itself
  • fields object? The collection of additional fields to log with the message

warn

lib/basic.js:66-66

Forwards to console.warn. Combines the fields provided with the standard fields.

Parameters

  • msg string The message itself
  • fields object? The collection of additional fields to log with the message

error

lib/basic.js:75-75

Forwards to console.error. Combines the fields provided with the standard fields.

Parameters

  • msg string The message itself
  • fields object? The collection of additional fields to log with the message

fatal

lib/basic.js:85-88

Forwards to console.error. Combines the fields provided with the standard fields. NOTE: Also exits the process with a code of 1.

Parameters

  • msg string The message itself
  • fields object? The collection of additional fields to log with the message

logRequest

lib/http.js:24-36

Takes an object representing an HTTP request and a message. Creates a set of logging fields to extract certain data from the request and combines them with the standard fields. Logs at level INFO.

Parameters

  • msg string The message itself
  • req object A representation of an HTTP request, abstracted from any particular implentation.

Examples

// logging from koa
const request = {
  header: ctx.request.header,
  protocol: ctx.protocol,
  remoteAddress: ctx.originalUrl,
  url: ctx.url,
  method: ctx.method,
  contentLength: ctx.request.length
}
logRequest('HTTP request', request)

logResponse

lib/http.js:60-73

Takes an object representing an HTTP response and a message. Creates a set of logging fields to extract certain data from the response and combines them with the standard fields. Logs at level INFO.

Parameters

  • msg string The message itself
  • res object A representation of an HTTP response, abstracted from any particular implentation.

Examples

// logging from koa
const response = {
  header: ctx.request.header,
  protocol: ctx.protocol,
  remoteAddress: ctx.originalUrl,
  url: ctx.url,
  method: ctx.method,
  contentLength: ctx.response.length,
  status: ctx.status
}
logResponse('HTTP response', response)
0.4.2

5 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.3.4

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.3

5 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

1.0.0

7 years ago