JSPM

@kaotypr/liblog

1.1.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q44114F
  • License MIT

Configurable logging utility for JavaScript/TypeScript libraries with scope-based logging control

Package Exports

  • @kaotypr/liblog
  • @kaotypr/liblog/dist/index.mjs

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@kaotypr/liblog) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@kaotypr/liblog

A lightweight and configurable logging utility for JavaScript/TypeScript libraries with scope-based logging control.

Installation

npm install @kaotypr/liblog

Usage

import { createLiblog, LiblogConfig } from '@kaotypr/liblog';

// Initialize with scopes
type Scopes = 'api' | 'auth';
const config = new LiblogConfig<Scopes>();

// Create loggers
const defaultLog = createLiblog(config);
const apiLog = createLiblog(config, { scope: 'api' });
const authLog = createLiblog(config, { 
  scope: 'auth',
  scopePrefix: (scope) => `${scope.toUpperCase()} >>` // Custom prefix
});

// Enable logging for specific scopes
config.set(['api', 'auth'], {
  info: true,
  error: true
});

// Use loggers
defaultLog.debug('Debug message');  // No output, as default is false for all scopes
apiLog.info('Request received');    // [api]: Request received
authLog.error('Login failed');      // AUTH >> Login failed

// Configure log level config from the logger
apiLog.config.set({ info: false });

Features

  • Scope-based logging with TypeScript support
  • Configurable log levels: verbose, info, warning, error, dir, table
  • Customizable scope prefixes
  • Global and instance-level configuration

Documentation

For detailed documentation and examples, visit our documentation.

License

MIT