0.0.2 • Published 1 year ago

@kirklin/logger v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

logger

A simple JavaScript logging library that allows you to log messages with levels (Trace, Debug, Info, Warn, and Error) and optional fields and custom colors.

  • Built for node and the browser
  • Use groups in the browser to reduce clutter

Install

pnpm i @kirklin/logger

Example Usage

import { field, logger } from "@kirklin/logger";

logger.info("Loading container",
	field("msg", 1),
	field("msg2", {"key":value}));

Formatting

By default, the logger uses a different formatter depending on whether it detects it is running in the browser or not. A custom formatter can be set:

import { logger, Formatter } from "@kirklin/logger";

class MyFormatter extends Formatter {
	// implementation ...
}

logger.formatter = new MyFormatter();

License

MIT License © 2022-PRESENT Kirk Lin