1.1.3 • Published 1 year ago

@kaotypr/liblog v1.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@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

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago