-
-
Notifications
You must be signed in to change notification settings - Fork 150
Package specific logger configuration
Karsten Schmidt edited this page Oct 11, 2021
·
4 revisions
Several packages include support for a lightweight, configurable logging mechanism based on the ILogger
interface in the @thi.ng/logger package. By default these are merely using a dummy implementation (aka NULL_LOGGER
), which is 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/logger";
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, check out the logger provided by the @thi.ng/rstream-log package, which supports:
- nested/chained 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/logger";
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
- egf
- hdom
- interceptors
- pointfree-lang
- rstream
- rstream-csp
- rstream-query
- shader-ast
- system
- testament
- vector-pools
- webgl