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.
- 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
npm install @inkdropapp/logger
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')
import debug from 'debug'
import { createLogger } from '@inkdropapp/logger'
debug.enable('mymodule:*')
const logger = createLogger('mymodule')
logger.debug('Debug message from custom logger')
import { createLogger } from '@inkdropapp/logger'
const logger = createLogger('app', false) // Colors disabled
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
The package exports a default logger instance configured with namespace 'app' and automatic color detection.