Registry / observability / typescript-logging

typescript-logging

JSON →
library2.2.0jsnpmunverified

TypeScript Logging is a core library designed for adding robust logging capabilities to both web and Node.js projects. It is currently at version 2.2.0 and is actively maintained, with minor releases adding new features such as file logging and rollover support via the `typescript-logging-node-channel` package. This package serves as the foundation; users must also install a specific 'flavor' package (e.g., `typescript-logging-category-style` or `typescript-logging-log4ts-style`) to gain concrete logging implementations and APIs. Version 2.x, a complete rewrite, is not compatible with version 1.x. Key differentiators include offering two distinct API styles: a hierarchical, category-based approach and a style mimicking Log4j/log4ts for familiarity, providing flexibility for different development preferences.

npm install typescript-logging
INSTALL
IMPORT
SIG · TYPESCRIPT-LOGGING
T
typescript-logging
observabilityjavascriptv2.2.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

LogLevel
✓ import { LogLevel } from 'typescript-logging';
✗ const { LogLevel } = require('typescript-logging');
Core enum for defining logging thresholds. The library is primarily designed for ESM usage in v2+.
CategoryProvider, Category
✓ import { CategoryProvider, Category } from 'typescript-logging-category-style';
✗ import CategoryProvider from 'typescript-logging-category-style'; const { Category } = require('typescript-logging-category-style');
Essential classes for setting up and utilizing the category-style hierarchical logging API. ESM-first.
Log4TSProvider, Logger
✓ import { Log4TSProvider, Logger } from 'typescript-logging-log4ts-style';
✗ import Logger from 'typescript-logging-log4ts-style'; const { Log4TSProvider } = require('typescript-logging-log4ts-style');
Primary classes for configuring and using the log4ts-compatible logging API. ESM-first.

Demonstrates how to configure the Category-style logging provider and obtain hierarchical loggers for different modules, logging messages at various levels.

/*--- LogConfig.ts ---*/ import {CategoryProvider, Category} from "typescript-logging-category-style"; const provider = CategoryProvider.createProvider("ExampleProvider"); export function getLogger(name: string): Category { return provider.getCategory(name); } /*--- Person.ts ---*/ import {getLogger} from "./LogConfig"; /* Root categories can and probably will be defined elsewhere, this is just an example */ const logModel = getLogger("model"); /* Create child categories based on a parent category, effectively allowing you to create a tree of loggers when needed */ const logPerson = logModel.getChildCategory("Person"); function example(value: string) { logPerson.debug(() => `Example function called with value ${value}`); try { // Awesome code here... logPerson.getChildCategory("example()").debug(() => "Child category again"); } catch (e: any) { logPerson.error(() => "Awesome code failed unexpectedly", e); } finally { logPerson.debug(() => "Example function completed"); } } // Example usage call example("test-value");
Debug
Known issues
breakingVersion 2.x of `typescript-logging` is a complete rewrite and is not backward compatible with version 1.x APIs. Existing code using v1 will break.
fix
Refer to the migration guide in the package documentation (`/migration` section) and update all logging logic to conform to the new v2 API structure. This typically involves updating imports and logger initialization.
affects: >=2.0.0
gotchaThe `typescript-logging` core package provides only interfaces and basic types. To get functional logging, you must install and configure a specific 'flavor' package (e.g., `typescript-logging-category-style` or `typescript-logging-log4ts-style`) alongside the core library.
fix
Install your preferred flavor package (e.g., `npm install --save typescript-logging-category-style`) and follow its documentation to set up the logging provider and obtain logger instances.
affects: >=2.0.0
deprecatedThe `LogLevel.Off` value was introduced in version 2.1.0. While it provides an explicit way to disable logging for a category, it might subtly alter behavior or require adjustments in existing configurations that implicitly handled disabled logging.
fix
Review any log level configurations that might be impacted by the introduction of `LogLevel.Off`. Explicitly use `LogLevel.Off` where logging should be completely disabled, or other specific levels for active logging.
affects: >=2.1.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'createProvider')
Attempting to instantiate a logging provider (e.g., CategoryProvider or Log4TSProvider) directly from the `typescript-logging` core package, which only exports interfaces and not concrete implementations.
fix
Ensure you are importing the provider from the correct 'flavor' package, e.g., `import {CategoryProvider} from 'typescript-logging-category-style';` and that the flavor package is installed.
Module not found: Can't resolve 'typescript-logging-category-style'
The specific logging flavor package (e.g., `typescript-logging-category-style` or `typescript-logging-log4ts-style`) has not been installed, or the import path is incorrect.
fix
Install the required flavor package using npm: `npm install --save typescript-logging-category-style` (or your chosen flavor) and verify the import statement correctly references the package name and export.
Upgrade
Version history
2.2.0latest on npm
Audit
Dependencies
typescript-logging-category-stylerequiredRequired for the category-style logging API implementation.
typescript-logging-log4ts-stylerequiredRequired for the log4ts-style logging API implementation.
typescript-logging-node-channeloptionalOptional: Provides file logging and rollover support specifically for Node.js environments.
Agent activity
27 hits · last 30 days
node
24
OpenAI (training)
1
Resources
typescript-logging — npm install typescript-logging · libregistry