-
-
Notifications
You must be signed in to change notification settings - Fork 151
Package specific logger configuration
Karsten Schmidt edited this page Apr 7, 2020
·
4 revisions
Several packages include support for a lightweight, configurable logging mechanism (based on the ILogger
interface), which by default is merely using a dummy implementation (aka NULL_LOGGER
), not producing any outputs.
The snippet below shows how to configure the logger for the @thi.ng/webgl package to use a ConsoleLogger
(aka console.log
)...
import { ConsoleLogger, LogLevel } from "@thi.ng/api";
import { setLogger } from "@thi.ng/webgl";
setLogger(new ConsoleLogger("webgl", LogLevel.DEBUG));
Since the mechanism is interface based, other implementations can be used. For more advanced logging setups, I'd recommend using the logger provided by the @thi.ng/rstream-log package, which supports:
- nested loggers
- structured log messages
- transducer based transformations of log messages
- multiple output targets (incl. support for workers and file output)
import { LogLevel } from "@thi.ng/api";
import { Logger, formatString, writeConsole } from "@thi.ng/rstream-log";
import { setLogger } from "@thi.ng/webgl";
const logger = new Logger("webgl", LogLevel.DEBUG);
logger.subscribe(writeConsole(), formatString());
setLogger(logger);
The following packages all support the above-mentioned pattern, each using their own, package specific setLogger()
implementation...
- defmulti
- ecs
- interceptors
- pointfree-lang
- rstream
- rstream-csp
- rstream-query
- vector-pools
- webgl