Skip to main content
This release is a pre-release — the latest non-prerelease version of @logtape/logtape is 0.6.3. Jump to this version

@logtape/logtape@0.7.0-dev.93+f5a1599d
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
3 weeks ago (0.7.0-dev.93+f5a1599d)
function configure
configure<
TSinkId extends string,
TFilterId extends string,
>
(config: Config<TSinkId, TFilterId>): Promise<void>

Configure the loggers with the specified configuration.

Note that if the given sinks or filters are disposable, they will be disposed when the configuration is reset, or when the process exits.

Examples

Example 1

await configure({
  sinks: {
    console: getConsoleSink(),
  },
  filters: {
    slow: (log) =>
      "duration" in log.properties &&
      log.properties.duration as number > 1000,
  },
  loggers: [
    {
      category: "my-app",
      sinks: ["console"],
      level: "info",
    },
    {
      category: ["my-app", "sql"],
      filters: ["slow"],
      level: "debug",
    },
    {
      category: "logtape",
      sinks: ["console"],
      level: "error",
    },
  ],
});

Type Parameters

TSinkId extends string
TFilterId extends string

Parameters

The configuration.

Return Type

Promise<void>

Add Package

deno add jsr:@logtape/logtape

Import symbol

import { configure } from "@logtape/logtape";

---- OR ----

Import directly with a jsr specifier

import { configure } from "jsr:@logtape/logtape";

Add Package

npx jsr add @logtape/logtape

Import symbol

import { configure } from "@logtape/logtape";

Add Package

yarn dlx jsr add @logtape/logtape

Import symbol

import { configure } from "@logtape/logtape";

Add Package

pnpm dlx jsr add @logtape/logtape

Import symbol

import { configure } from "@logtape/logtape";

Add Package

bunx jsr add @logtape/logtape

Import symbol

import { configure } from "@logtape/logtape";