@kauai/logger
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

@kauai/logger CI Status version Known Vulnerabilities code style: prettier semantic-release Conventional Commits GitHub top language node version npm downloads License

A simple logger (based on pino).

By default, the logging level is equal to the value of the KAUAI_LOG_LEVEL environmental variable.

KAUAI_LOG_LEVEL=trace

Installation

npm install @kauai/logger

Usage

import { Logger } from "@kauai/logger";
const logger = new Logger({ level: Logger.getLevel("OTHER_ENV_NAME") });

or using the default import

import log from "@kauai/logger";
  • .fatal()
log.fatal("Bad error. Exiting...", { id: 1, someinfo: { a: 2 } });
  • .error()
try {
  doSomething();
} catch (error) {
  log.error("Something bad happened in the `doSomething`", { error });
}
  • .warn()
if (connection) {
  workWithConnection();
} else {
  log.warn("The connection has not been established", { reason });
}
  • .info()
server.on("listening", (port) => {
  log.info(`The server is listening`, { port });
});
  • .debug()
websocket.on("message", (message) => {
  log.debug("Received a message", { message });
});
  • .trace()
log.trace("Array length", { length: arr.length });

Readme

Keywords

Package Sidebar

Install

npm i @kauai/logger

Weekly Downloads

6

Version

1.0.1

License

AGPL-3.0-only

Unpacked Size

41.7 kB

Total Files

6

Last publish

Collaborators

  • b2broker-manager