Skip to content
Discussion options

You must be logged in to vote

Hi @KyleKing!

LogTape already supports exactly what you're looking for with implicit contexts. The issue in your example is likely that you haven't configured contextLocalStorage in your LogTape setup.

The Missing Configuration

To enable implicit contexts, you need to set contextLocalStorage in your configure() call:

import { AsyncLocalStorage } from "node:async_hooks";
import { configure } from "@logtape/logtape";

await configure({
  // ... your other settings ...
  contextLocalStorage: new AsyncLocalStorage(),
});

Without this configuration, withContext() won't inject implicit contexts into log messages, and LogTape will log a warning to the meta logger about the missing option.

Fixed …

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@KyleKing
Comment options

Answer selected by KyleKing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
2 participants