• TypeScript 95.6%
  • JavaScript 4.4%
Find a file
DigiToegankelijk NLdoc f89dc61933 Merge branch 'renovate/vitest-monorepo' into 'main'
chore(deps): update vitest monorepo to v4.0.16

See merge request logius/nldoc/lib/typescript/logger!215
2025-12-16 19:18:17 +00:00
.vscode feat: formatting using @toegang-voor-iedereen/configs 2025-04-02 14:50:21 +02:00
__test__ feat: initial logger package 2023-09-19 16:35:34 +02:00
src chore: fix deprecations 2025-07-30 14:27:55 +02:00
.editorconfig chore: set .editorconfig 2025-04-22 01:05:15 +00:00
.gitignore feat: initial logger package 2023-09-19 16:35:34 +02:00
.gitlab-ci.yml fix: update references (GitLab migration) 2025-04-04 15:48:53 +02:00
.npmrc fix: update references (GitLab migration) 2025-04-04 15:48:53 +02:00
.nvmrc chore(deps): update node.js to v24 2025-10-28 23:09:50 +00:00
.prettierignore feat: formatting using @toegang-voor-iedereen/configs 2025-04-02 14:50:21 +02:00
CHANGELOG.md chore(release): 1.1.81 2025-11-24 03:20:05 +00:00
CODEOWNERS chore: set CODEOWNERS 2025-04-22 00:25:26 +00:00
commitlint.config.ts feat: initial logger package 2023-09-19 16:35:34 +02:00
eslint.config.mjs fix: update references (GitLab migration) 2025-04-04 15:48:53 +02:00
LICENSE chore: add license 2025-04-15 00:19:43 +02:00
package-lock.json chore(deps): update vitest monorepo to v4.0.16 2025-12-16 19:09:40 +00:00
package.json chore(release): 1.1.81 2025-11-24 03:20:05 +00:00
prettier.config.mjs fix: update references (GitLab migration) 2025-04-04 15:48:53 +02:00
README.md chore: add acknowledgements 2025-08-18 13:25:21 +02:00
renovate.json chore: npm install twice 2025-11-05 14:12:04 +00:00
tsconfig.dist.json feat: formatting using @toegang-voor-iedereen/configs 2025-04-02 14:50:21 +02:00
tsconfig.json feat: formatting using @toegang-voor-iedereen/configs 2025-04-02 14:50:21 +02:00
vitest.config.ts feat: initial logger package 2023-09-19 16:35:34 +02:00

NLdoc TypeScript Logger

pipeline status coverage report Latest Release NPM Version

A TypeScript logger package that provides structured logging in ECS (Elastic Common Schema) format. Built on top of Pino for high-performance logging with environment-configurable settings.

Overview

This logger provides:

  • ECS-formatted structured logging for better log analysis
  • Environment-based configuration (logging enabled/disabled, trace levels)
  • Built-in metadata injection (logger version, environment, Node.js version)
  • TypeScript support with full type safety
  • High-performance logging through Pino

Getting Started

Prerequisites

  • Node.js >= 22

Installation

Install the package via npm:

npm install @nldoc/logger

Basic Usage

import { logger } from '@nldoc/logger';

// Simple logging
logger.info('Application started');

// Structured logging with additional context
logger.child({ userId: '123', module: 'auth' }).info('User logged in');

// Different log levels
logger.debug('Debug information');
logger.warn('Warning message');
logger.error('Error occurred');

Configuration

The logger can be configured through environment variables:

  • LOGGING_ENABLED (default: true) - Enable/disable logging
  • TRACE_ENABLED (default: false) - Enable trace-level logging
  • ENVIRONMENT (default: development) - Environment identifier
  • NODE_VERSION - Node.js version (automatically injected into logs)

Development

Local Setup

  1. Clone the repository:

    git clone https://gitlab.com/logius/nldoc/lib/typescript/logger.git
    cd typescript-logger
    
  2. Install dependencies:

    npm install
    
  3. Build the project:

    npm run build
    

Available Scripts

  • npm run test - Run the test suite with coverage
  • npm run build - Build TypeScript to JavaScript
  • npm run check - Type-check without emitting files
  • npm run lint - Lint the codebase
  • npm run format - Format code using Prettier
  • npm run fix - Auto-fix linting and formatting issues

API Documentation

For detailed Pino API documentation, see the official Pino documentation.

Testing

Run the test suite:

npm test

Contributing

We welcome contributions! Please ensure:

  1. All tests pass (npm test)
  2. Code is properly formatted (npm run format:check)
  3. Linting rules are followed (npm run lint)
  4. Type checking passes (npm run check)

License

This project is licensed under the European Union Public License 1.2 - see LICENSE for details.

Acknowledgements