Skip to main content

Built and signed on GitHub Actions

Simple logging library with zero dependencies for Deno/Node.js/Bun/browsers

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
2 weeks ago (0.6.3)
interface AnsiColorFormatterOptions

The various options for the ANSI color formatter.

Properties

optional
timestamp:
"date-time-timezone"
| "date-time-tz"
| "date-time"
| "time-timezone"
| "time-tz"
| "time"
| "date"
| "rfc3339"
| ((ts: number) => string)

The timestamp format. This can be one of the following:

  • "date-time-timezone": The date and time with the full timezone offset (e.g., "2023-11-14 22:13:20.000 +00:00").
  • "date-time-tz": The date and time with the short timezone offset (e.g., "2023-11-14 22:13:20.000 +00").
  • "date-time": The date and time without the timezone offset (e.g., "2023-11-14 22:13:20.000").
  • "time-timezone": The time with the full timezone offset but without the date (e.g., "22:13:20.000 +00:00").
  • "time-tz": The time with the short timezone offset but without the date (e.g., "22:13:20.000 +00").
  • "time": The time without the date or timezone offset (e.g., "22:13:20.000").
  • "date": The date without the time or timezone offset (e.g., "2023-11-14").
  • "rfc3339": The date and time in RFC 3339 format (e.g., "2023-11-14T22:13:20.000Z").

Alternatively, this can be a function that accepts a timestamp and returns a string.

The default is "date-time-tz".

optional
timestampStyle: AnsiStyle | null

The ANSI style for the timestamp. "dim" is used by default.

optional
timestampColor: AnsiColor | null

The ANSI color for the timestamp. No color is used by default.

optional
levelStyle: AnsiStyle | null

The ANSI style for the log level. "bold" is used by default.

optional
levelColors: Record<LogLevel, AnsiColor | null>

The ANSI colors for the log levels. The default colors are as follows:

  • "debug": "blue"
  • "info": "green"
  • "warning": "yellow"
  • "error": "red"
  • "fatal": "magenta"
optional
categoryStyle: AnsiStyle | null

The ANSI style for the category. "dim" is used by default.

optional
categoryColor: AnsiColor | null

The ANSI color for the category. No color is used by default.

Add Package

deno add jsr:@logtape/logtape

Import symbol

import { type AnsiColorFormatterOptions } from "@logtape/logtape";

---- OR ----

Import directly with a jsr specifier

import { type AnsiColorFormatterOptions } from "jsr:@logtape/logtape";

Add Package

npx jsr add @logtape/logtape

Import symbol

import { type AnsiColorFormatterOptions } from "@logtape/logtape";

Add Package

yarn dlx jsr add @logtape/logtape

Import symbol

import { type AnsiColorFormatterOptions } from "@logtape/logtape";

Add Package

pnpm dlx jsr add @logtape/logtape

Import symbol

import { type AnsiColorFormatterOptions } from "@logtape/logtape";

Add Package

bunx jsr add @logtape/logtape

Import symbol

import { type AnsiColorFormatterOptions } from "@logtape/logtape";