@inkdropapp/logger
v4.0.0
Published
Logger for Inkdrop
Readme
@inkdropapp/logger
A lightweight logging library for Inkdrop that provides structured logging with multiple log levels. Built on top of the popular debug package, it offers colored output and environment-aware configuration.
Features
- Multiple log levels: debug, info, warn, error
- Colored output: Automatically enabled in browsers and configurable in Node.js
- Namespace support: Create custom loggers with specific namespaces
- Environment detection: Smart color enabling based on environment
- Console method binding: Each log level uses the appropriate console method
Installation
npm install @inkdropapp/loggerUsage
Basic Usage
import debug from 'debug'
import logger from '@inkdropapp/logger'
// Enable debug output for your namespace
debug.enable('app:*')
// Use the default logger
logger.debug('Starting Inkdrop..')
logger.info('Application initialized')
logger.warn('This is a warning')
logger.error('An error occurred')Custom Logger
import debug from 'debug'
import { createLogger } from '@inkdropapp/logger'
debug.enable('mymodule:*')
const logger = createLogger('mymodule')
logger.debug('Debug message from custom logger')Disable Colors
import { createLogger } from '@inkdropapp/logger'
const logger = createLogger('app', false) // Colors disabledAPI
createLogger(name: string, colorEnabled?: boolean)
Creates a new logger instance with the specified namespace.
name: The namespace for the logger (e.g., 'app', 'mymodule')colorEnabled: Optional boolean to enable/disable colors (defaults to environment detection)
Returns an object with four logging methods:
debug(message): Debug level logginginfo(message): Info level loggingwarn(message): Warning level loggingerror(message): Error level logging
Default Export
The package exports a default logger instance configured with namespace 'app' and automatic color detection.
