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
a week ago (0.7.1)
function withFilter
withFilter(
sink: Sink,
filter: FilterLike,
): Sink

Turns a sink into a filtered sink. The returned sink only logs records that pass the filter.

Examples

Filter a console sink to only log records with the info level

const sink = withFilter(getConsoleSink(), "info");

Parameters

sink: Sink

A sink to be filtered.

filter: FilterLike

A filter to apply to the sink. It can be either a filter function or a LogLevel string.

Return Type

A sink that only logs records that pass the filter.

Add Package

deno add jsr:@logtape/logtape

Import symbol

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

---- OR ----

Import directly with a jsr specifier

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

Add Package

npx jsr add @logtape/logtape

Import symbol

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

Add Package

yarn dlx jsr add @logtape/logtape

Import symbol

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

Add Package

pnpm dlx jsr add @logtape/logtape

Import symbol

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

Add Package

bunx jsr add @logtape/logtape

Import symbol

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