-
-
Notifications
You must be signed in to change notification settings - Fork 38
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
LogTape provides excellent lazy evaluation for avoiding expensive computations:
logger.debug("Result: {value}", () => ({ value: expensive() }));However, this only works for synchronous operations. For async operations, there's no way to avoid the computation:
// This always runs expensiveAsync(), even if debug is disabled
const result = await expensiveAsync();
logger.debug("Result: {result}", { result });Proposed
Add an isEnabled(level) method to the Logger interface:
if (logger.isEnabled("debug")) {
const result = await expensiveAsync();
logger.debug("Result: {result}", { result });
}Alternatively, maybe the callback API could accept async functions?
Use case
Currently I want to query logtape to determine if I should run expensive analysis (like ESBuild’s analyzeMetafile()) only when debug logging is enabled.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request