No description
Find a file
2026-03-14 04:39:24 +01:00
docs docs: add user guide, cookbook, and rewrite README 2026-03-14 04:33:53 +01:00
scripts chore: remove redundant script 2025-04-25 18:44:19 +02:00
src feat(manager): set manager on created loggers, fix clear for placeholders 2026-03-14 00:23:09 +01:00
tests/unit test(manager): add tests for manager assignment and propagation 2026-03-14 02:32:20 +01:00
vendor chore: add tiara-gitflow-spec as vendor submodule 2026-03-13 22:38:27 +01:00
.gitignore chore: make tests work 2025-04-25 19:19:40 +02:00
.gitmodules chore: add tiara-gitflow-spec as vendor submodule 2026-03-13 22:38:27 +01:00
bitbucket-pipelines.yml style(ci): add commands for removing test-reports 2025-05-01 22:50:33 +02:00
configure refactor: change autoconf script to be more verbose 2025-04-25 18:04:23 +02:00
configure.ac refactor: change autoconf script to be more verbose 2025-04-25 18:04:23 +02:00
CONTRIBUTING.md feat(init): publishing 2025-04-25 16:17:37 +02:00
eslint.config.mjs chore: add eslint with typescript-eslint, align package.json scripts 2026-03-13 22:38:36 +01:00
jest.config.mjs fix: correct jest roots and test import path 2026-03-13 22:38:41 +01:00
LICENSE refactor: update build environment 2025-04-25 18:43:19 +02:00
Makefile feat(make): introduce build flags 2025-04-25 19:32:14 +02:00
package-lock.json chore: add eslint with typescript-eslint, align package.json scripts 2026-03-13 22:38:36 +01:00
package.json chore: add eslint with typescript-eslint, align package.json scripts 2026-03-13 22:38:36 +01:00
README.md docs: add user guide, cookbook, and rewrite README 2026-03-14 04:33:53 +01:00
TODO todo(13): in-progress 2026-03-14 04:39:24 +01:00
tsconfig.debug.json chore: redefine tsc config 2025-04-25 17:50:00 +02:00
tsconfig.json chore: redefine tsc config 2025-04-25 17:50:00 +02:00
tsconfig.node.json feat(init): publishing 2025-04-25 16:17:37 +02:00
typedoc.json feat: initialize tests, docs and refactor 2025-04-25 16:17:46 +02:00

esm-logging

A quasi-port of the Python standard library logging module to ECMAScript. Browser-compatible, zero dependencies.

Why?

Logging is important. It is important for debugging purposes, leading to faster and more resilient development, for traceability leading to better security. Most logging libraries I've discovered didn't satisfy me, introduced weird concepts and all in all just weren't great. Other programming language ecosystems offer way nicer logging facilities. Take Rust for example, or... Python! Python has PEP, giving it a very structured approach towards implementing new features and that's also how its logging facilities came to be (PEP 282). Python's logging facilities are implemented by the logging module, which is part of the standard library and has been since 2002. It was originally authored by Vinay Sajip.

Installation

npm install @administratrix/esm-logging

Quick start

import * as logging from '@administratrix/esm-logging';

// one-shot configuration: sets up a console handler on the root logger
logging.config.basicConfig({ level: logging.log_level.INFO });

// create a logger for this module
const logger = logging.manager.MANAGER.getLogger('myapp');

logger.info('Application started');
logger.warning('Something looks off');
logger.error('Something went wrong');

Concepts

The logging system is built around four core components:

  • Loggers expose the interface that application code uses directly.
  • Handlers send log records to the appropriate destination (console, stderr, custom writable streams).
  • Formatters control the layout of log records in the final output.
  • Filters provide fine-grained control over which records to output.

Loggers are organized in a dot-separated hierarchy. A logger named app.db is a child of the logger named app. Log records propagate up the hierarchy, so a handler attached to app will also receive records from app.db.

Log levels

Constant Value Purpose
CRITICAL 50 A serious error, the program may not continue
ERROR 40 An error that prevented some operation
WARNING 30 Something unexpected, but the software still works
INFO 20 Confirmation that things work as expected
DEBUG 10 Detailed diagnostic information
NOTSET 0 All messages are processed

Documentation

See docs/ for the full user guide and docs/logging-cookbook.md for recipes and patterns.

API reference can be generated with TypeDoc:

npm run build/doc

Roadmap

  • quasi-port of the logging module with minimal adaptation
  • add documentation
  • add support for asynchronous calls
  • implement Open Cybersecurity Schema Framework (OCSF) formatter
  • implement browser local storage handler as a replacement for file handler

License

UNLICENSED