tslog  by fullstack-build

TypeScript and JavaScript logging library

Created 6 years ago
1,628 stars

Top 24.9% on SourcePulse

GitHubView on GitHub
1 Expert Loves This Project
Project Summary

A universal logger for TypeScript and JavaScript, tslog provides a powerful, flexible, and developer-friendly logging experience across diverse environments including Node.js, browsers, Deno, and Bun. It targets developers seeking enhanced debugging, structured logging for observability, and robust customization, offering benefits like pretty or JSON output, secret masking, and hierarchical sub-loggers.

How It Works

This library employs a highly customizable, pluggable architecture. It supports both human-readable "pretty" output and machine-parseable JSON formats, with configurable log levels and extensive options for object/error interpolation and secret masking. A key design choice is its universal runtime support and deep TypeScript integration, including native source map support for accurate stack traces. Its lifecycle model allows deep overwrites of logging steps, from masking to formatting and transport, enabling integration with external services.

Quick Start & Requirements

  • Installation: npm install tslog
  • Prerequisites:
    • Node.js: For full source map support, requires "type": "module" in package.json and running with --enable-source-maps.
    • TypeScript: tsconfig.json should include "inlineSourceMap": true and target: "es2020" for accurate stack traces.
    • Deno/Bun: Supported with specific import/run commands shown in examples.
  • Links: Examples provided in the README serve as quick-start guides.

Highlighted Details

  • Universal Runtime Support: Seamlessly works across Node.js, Deno, Bun, browsers, and workers.
  • TypeScript Native: Fully typed with first-class TypeScript support and accurate source map integration.
  • Flexible Output Formats: Offers pretty, JSON, or hidden output, with extensive customization for templates and styles.
  • Advanced Features: Includes sub-loggers with inheritance, secret masking, object/error interpolation, and AsyncLocalStorage-based request ID tracking in Node.js.
  • Performance Optimization: Provides options like hideLogPositionForProduction to tune performance for production environments.

Maintenance & Community

The project appears to be maintained by a single developer, with a call for sponsors to support ongoing work. No specific community channels (e.g., Discord, Slack) or details on a broader contributor base are provided in the README.

Licensing & Compatibility

The README does not explicitly state the software license. This omission requires further investigation for adoption decisions, particularly concerning commercial use or linking with closed-source projects.

Limitations & Caveats

Default settings prioritize developer experience and may require tuning for optimal production performance. The lack of an explicitly stated license is a significant adoption blocker. Node.js ESM usage necessitates specific configuration and runtime flags for full source map functionality.

Health Check
Last Commit

1 day ago

Responsiveness

Inactive

Pull Requests (30d)
11
Issues (30d)
0
Star History
3 stars in the last 30 days

Explore Similar Projects

Starred by Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems"), Jeffrey Morgan Jeffrey Morgan(Cofounder of Ollama), and
3 more.

modelfusion by vercel

0.1%
1k
TypeScript library for building AI applications
Created 3 years ago
Updated 2 years ago
Feedback? Help us improve.