Skip to content

emit-js/log

Repository files navigation

@emit-js/log

emit logger

log

Install

npm install @emit-js/emit @emit-js/log

Setup

const emit = require("@emit-js/emit")()
require("@emit-js/log")(emit)

This creates the emit.log emitter.

Log levels

There are five log levels: debug, trace, info, warn, and error.

By default, the logger only logs warn or above, but you can change that with logLevel:

emit("logLevel", "debug")

You could also set the environment variable LOG=debug.

Logs all events

By default, the logger logs all events at log level debug.

You might want to change debug logs to info for certain events:

emit("logLevel", "myEvent", { debug: "info" })

Manual logging

emit.log("logs at info by default")
emit.log("warn", "warning!")