Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Simple logging library with zero dependencies for Deno/Node.js/Bun/browsers
The ANSI colors. These can be used to colorize text in the console.
A text formatter that uses ANSI colors to format log records.
The various options for the ANSI color formatter.
The ANSI text styles.
An async sink is a function that accepts a log record and asynchronously processes it. This type is used with fromAsyncSink to create a regular sink that properly handles asynchronous operations.
Compares two log levels.
A configuration error.
Configure the loggers with the specified configuration.
Configure sync loggers with the specified configuration.
A console formatter is a function that accepts a log record and returns an array of arguments to pass to console.log.
A generic interface for a context-local storage. It resembles the AsyncLocalStorage API from Node.js.
The default console formatter.
The default text formatter. This formatter formats log records as follows:
Dispose of the disposables.
Dispose of the sync disposables. Async disposables will be untouched, use dispose if you have async sinks.
A filter is a function that accepts a log record and returns true if the
record should be passed to the sink.
A filter-like value is either a Filter or a LogLevel.
null is also allowed to represent a filter that rejects all records.
Creates a sink that buffers log records until a trigger level is reached. This pattern, known as "fingers crossed" logging, keeps detailed debug logs in memory and only outputs them when an error or other significant event occurs.
Options for the fingersCrossed function.
Converts an async sink into a regular sink with proper async handling. The returned sink chains async operations to ensure proper ordering and implements AsyncDisposable to wait for all pending operations on disposal.
Get an ANSI color formatter with the specified options.
Get the current configuration, if any. Otherwise, null.
A console sink factory that returns a sink that logs to the console.
Get a JSON Lines formatter with the specified options. The log records will be rendered as JSON objects, one per line, which is a common format for log files. This format is also known as Newline-Delimited JSON (NDJSON). It looks like this:
Returns a filter that accepts log records with the specified level.
Get a logger with the given category.
Lists all available log levels with the order of their severity.
The "trace" level goes first, and the "fatal" level goes last.
A factory that returns a sink that writes to a WritableStream.
Get a text formatter with the specified options. Although it's flexible enough to create a custom formatter, if you want more control, you can create a custom formatter that satisfies the TextFormatter type instead.
Checks if a string is a valid log level. This function can be used as as a type guard to narrow the type of a string to a LogLevel.
The default JSON Lines formatter. This formatter formats log records as JSON objects, one per line, which is a common format for log files. It looks like this:
Options for the getJsonLinesFormatter function.
The severity level of a LogRecord.
A function type for logging methods in the Logger interface.
Parses a log level from a string.
Reset the configuration. Mostly for testing purposes.
Reset the configuration. Mostly for testing purposes. Will not clear async sinks, only use with sync sinks. Use reset if you have async sinks.
A sink is a function that accepts a log record and prints it somewhere.
Thrown exceptions will be suppressed and then logged to the meta logger,
a Logger with the category ["logtape", "meta"]. (In that case,
the meta log record will not be passed to the sink to avoid infinite
recursion.)
A text formatter is a function that accepts a log record and returns a string.
Converts a FilterLike value to an actual Filter.
Runs a callback with the given implicit context. Every single log record in the callback will have the given context.
Turns a sink into a filtered sink. The returned sink only logs records that pass the filter.