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

@logtape/logtape@0.9.0-dev.114+327c9473
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 months ago (0.9.0-dev.114+327c9473)
method Logger.with
Logger.with(properties: Record<string, unknown>): Logger

Get a logger with contextual properties. This is useful for log multiple messages with the shared set of properties.

const logger = getLogger("category");
const ctx = logger.with({ foo: 123, bar: "abc" });
ctx.info("A message with {foo} and {bar}.");
ctx.warn("Another message with {foo}, {bar}, and {baz}.", { baz: true });

The above code is equivalent to:

const logger = getLogger("category");
logger.info("A message with {foo} and {bar}.", { foo: 123, bar: "abc" });
logger.warn(
  "Another message with {foo}, {bar}, and {baz}.",
  { foo: 123, bar: "abc", baz: true },
);

Parameters

properties: Record<string, unknown>

Return Type

Add Package

deno add jsr:@logtape/logtape

Import symbol

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

---- OR ----

Import directly with a jsr specifier

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

Add Package

npx jsr add @logtape/logtape

Import symbol

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

Add Package

yarn dlx jsr add @logtape/logtape

Import symbol

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

Add Package

pnpm dlx jsr add @logtape/logtape

Import symbol

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

Add Package

bunx jsr add @logtape/logtape

Import symbol

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