npm.io
1.0.0-alpha.59 • Published 2 years ago

openspan

Licence
MIT
Version
1.0.0-alpha.59
Deps
0
Size
23 kB
Vulns
0
Weekly
0
Stars
3

Telemetry tools

Console

Console provides methods debug, info, warn, and error to log messages with different severity levels.

(message: string, ...values: any[], attributes?: object) => void

Messages are formatted using util.format and writes a structured message to stdout or stderr.

The last argument can be an object with additional attributes to be included in the log entry.

Log entry format:

time: string      # ISO 8601 timestamp
severity: string  # DEBUG, INFO, WARN, ERROR
message: string
attributes: object
context: object   # context passed to the constructor

Example

const console = new Console({ context: 'my-app' })

console.info('Hello, %s!', 'world', { foo: 'bar' })

/*
severity: info
context: my-app
time: 2020-01-01T00:00:00.000Z
message: Hello, world!
attributes:
  foo: bar
*/
import { console } from 'openspan'

console.configure({ level: 'warn' })
console.info('ingnored')