@inkdropapp/logger
TypeScript icon, indicating that this package has built-in type declarations

4.0.0 • Public • Published

@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/logger

Usage

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 disabled

API

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 logging
  • info(message): Info level logging
  • warn(message): Warning level logging
  • error(message): Error level logging

Default Export

The package exports a default logger instance configured with namespace 'app' and automatic color detection.

Readme

Keywords

Package Sidebar

Install

npm i @inkdropapp/logger

Weekly Downloads

20

Version

4.0.0

License

MIT

Unpacked Size

7.01 kB

Total Files

10

Last publish

Collaborators

  • craftzdog