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
pnpm i @kirklin/logger
import { field, logger } from "@kirklin/logger";
logger.info("Loading container",
field("msg", 1),
field("msg2", {"key":value}));
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();