Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@variablesoftware/logface

variablesoftware1.3kMIT0.6.0TypeScript support: included

πŸŽ›οΈπŸͺ΅πŸ˜Ž A fun, lightweight, structured console-style logger with tag-based filtering for TypeScript projects.

logger, console, structured, structured-logging, typescript, debug, logface, tags, loglevel, logging, log, lightweight, nodejs

readme

@variablesoftware/logface πŸŽ›οΈπŸͺ΅πŸ˜Ž

Test Suite NPM version License Coverage Bundle Size Downloads PRs Welcome

πŸŽ›οΈπŸͺ΅πŸ˜Ž A fun, lightweight, structured console-style logger with tag-based filtering for TypeScript projects.


✨ Features

  • Drop-in replacements for console.* methods: debug, info, warn, error, log
  • Scoped tagging via log.options({ tag })
  • Filters logs using LOG or LOG_VERBOSE environment variables (supports wildcards)
  • Runtime log level: log.level = 'warn' or log.setLogLevel('warn') to suppress lower levels (unless LOG/LOG_VERBOSE is set)
  • Per-call configuration: timestamps, level formatting, and custom tags
  • Wildcard filtering support (e.g. auth:*, metrics*)
  • Global setup via log.setup({ ... })
  • Designed for Node.js and edge runtimes
  • Debug output is always gated: debug logs only appear if LOG/LOG_VERBOSE match, or if log.level is 'debug' and DEBUG=1 is set
  • log.level = 'silent' or log.setLogLevel('silent') suppresses all output
  • All log filtering logic falls back to LOG/LOG_VERBOSE if set, otherwise uses the runtime log level

πŸš€ Install

pnpm add @variablesoftware/logface

πŸ”§ Quick Usage

import { log } from "@variablesoftware/logface";

// Basic usage
log.debug("Boot sequence initiated");
log.info("App started on port %d", 3000);
log.warn("Disk usage at %d%%", 91);
log.error("Database connection failed: %s", err.message);

// Scoped/tagged logs
log.options({ tag: "auth" }).debug("User login event");
log.options({ tag: "metrics", timestamp: true }).info("Memory: %dMB", 182);
log.options({ tag: "api", levelShort: false }).warn("Rate limit exceeded");

// Global setup
log.setup({ timestamp: true, levelShort: false });

// Runtime log level (NEW)
log.level = "warn"; // Only warn, error, and log will be emitted
log.setLogLevel("error"); // Only error and log will be emitted
log.level = "silent"; // Suppress all output

// Restore to default
log.level = "debug";

πŸ“€ Output Format

[D][init] Booting...
[I][auth] Login successful
[L][metrics] 200 OK

Use log.setup() to enable timestamps or full level names.


πŸ” Filtering

Use LOG or LOG_VERBOSE to filter logs by tag or level:

LOG=auth node app.js
LOG=metrics,debug,auth* node app.js
LOG="!foo;auth,debug" node app.js   # Negation: suppress 'foo' unless also matches 'auth' or 'debug'
  • Wildcards are supported (e.g. auth:*, metrics*).
  • Negation is supported: Prefix a pattern with ! to suppress logs matching that pattern, unless also matched by a positive pattern. Example: LOG="!foo;auth,debug" suppresses logs with tag foo unless they also match auth or debug.
  • If neither is set, you can control output at runtime:
log.level = "warn"; // Only warn, error, and log
log.level = "silent"; // Suppress all output

Debug logs are only shown if LOG/LOG_VERBOSE match, or if log.level is 'debug' and DEBUG=1 is set in the environment.


πŸ“š Full Guide

For wildcard matching, structured output, test helpers, global setup, and advanced filtering:

➑️ See LOGGING.md for full logging level guidance


πŸ“„ License

MIT Β© Rob Friedman / Variable Software


Built with ❀️ by @variablesoftware
Thank you for downloading and using this project. Pull requests are warmly welcomed!


🌐 Inclusive & Accessible Design

  • Naming, logging, error messages, and tests avoid cultural or ableist bias
  • Avoids assumptions about input/output formats or encodings
  • Faithfully reflects user data β€” no coercion or silent transformations
  • Designed for clarity, predictability, and parity with underlying platforms (e.g., Cloudflare APIs)
  • Works well in diverse, multilingual, and inclusive developer environments

Logface Configuration

Logface supports powerful customization via a config file. You can control emoji, color, and more for your log output.

Quick Start

  1. Copy the example config:
    cp logface.example.config.js logface.config.js
  2. Edit logface.config.js to your liking.

Example: Multiple Emoji Sets & Randomization

// logface.config.js
module.exports = {
  emojiRandom: true, // Random emoji per log message
  emojis: {
    debug: ["πŸ›", "πŸ”", "🦠"],
    info: ["ℹ️", "πŸ’‘", "🧭"],
    log: ["πŸ“", "πŸ“„", "πŸ—’οΈ"],
    warn: ["⚠️", "🚧", "πŸ›‘"],
    error: ["πŸ”₯", "πŸ’₯", "πŸ’£"],
  },
  colorEnabled: true, // Enable/disable color
  colorLibrary: "chalk", // 'chalk', 'picocolors', 'colorette', or 'kleur'
};

Disabling Emoji/Color in Tests

Logface disables emoji and color automatically during tests for stable output. You can also set these manually:

module.exports = {
  emojiRandom: false,
  emojis: { debug: "", info: "", log: "", warn: "", error: "" },
  colorEnabled: false,
};

Supported Config Options

  • emojiRandom: true for random emoji per log, false for fixed.
  • emojis: Object mapping log levels to emoji (array or string).
  • colorEnabled: Enable/disable color output.
  • colorLibrary: Choose color library: 'chalk', 'picocolors', 'colorette', 'kleur'.

.js vs .mjs

  • Use .js for CommonJS or ESM (depends on your package.json type).
  • Use .mjs for guaranteed ESM.

Example: ESM Config

// logface.config.mjs
export default {
  emojiRandom: true,
  emojis: {
    debug: ["πŸ›", "πŸ”", "🦠"],
    info: ["ℹ️", "πŸ’‘", "🧭"],
    log: ["πŸ“", "πŸ“„", "πŸ—’οΈ"],
    warn: ["⚠️", "🚧", "πŸ›‘"],
    error: ["πŸ”₯", "πŸ’₯", "πŸ’£"],
  },
  colorEnabled: true,
  colorLibrary: "picocolors",
};

Tips

  • Add logface.config.js to your .gitignore to avoid committing user-specific config.
  • See logface.example.config.js for a template.

For more, see LOGGING.md.

changelog

0.6.0 (2025-06-07)

0.5.2 (2025-06-01)

Bug Fixes

  • Refactor code structure for improved readability and maintainability (347a094)

0.5.1 (2025-05-27)

Bug Fixes

  • tests: ensure build output exists before running tests πŸ› οΈβœ… (b41f5ec)

0.5.0 (2025-05-27)

Bug Fixes

  • husky: uncomment nvm and corepack commands for pre-push hook πŸ› οΈ (aa87ed7)
  • tests(emojis): enhance user emojis reference validation in dynamic config tests 🐞✨ (4f9e114)
  • tests: enhance user emojis reference validation in dynamic config tests 🐞✨ (77cfa35)
  • tests: enhance user emojis reference validation in dynamic config tests 🐞✨ (dd1a411)
  • types: add type declarations for optional color libraries 🎨 (1aa27fe)
  • types: update type declarations from any to unknown for optional color libraries 🎨 (3a3f273)

Features

  • config: add example configuration for emoji randomization and color options πŸŽ‰ (c5e66a1)
  • config: enhance emoji options and improve config loading tests πŸŽ‰ (1b41833)
  • logging: add negation filtering support for log patterns πŸŽ‰ (0836ecb)
  • logging: enhance LOG pattern support with negation and multiple delimiters πŸŽ‰ (f623885)
  • tests: add comprehensive unit tests for logface functionality (0609f33)
  • tests: update user emojis reference in dynamic config tests 🐞✨ (95f1214)

0.4.0 (2025-05-25)

Bug Fixes

  • add linting step to release scripts for improved code quality (fc076eb)
  • add linting step to version bump scripts for improved code quality (3dfee5d)
  • handle optional color library imports with error handling (70fe972)

Features

  • add reusable log prefix matching helpers with regex support (20e04bf)
  • add user config loading and reloading functionality (e9d9b66)
  • enhance config loading functionality and improve log prefix matching tests (0d0bff2)
  • enhance log prefix matching helpers to support wildcard and optional tags (958239b)

0.3.0 (2025-05-23)

Bug Fixes

  • update parameter name in setLevel method and improve test assertions for idiomatic usage (576a0c8)

Features

  • add setLevel and getLevel methods for runtime log level management (37c4bd4)

0.2.9 (2025-05-21)

Bug Fixes

  • update type assertion for logface methods and add SMOKE environment variable in workflow (1021d8d)

0.2.0 (2025-05-09)

Bug Fixes

  • add set -x to pre-commit and pre-push hooks for better debugging; update build scripts to use pnpm (767b2f7)
  • correct export statement for Logger type (ec3c112)
  • reorder lint and build:test commands in pre-push hook for improved execution flow (bd78f56)
  • update .gitignore to include additional archive formats; remove obsolete npm smoke test and related files (9c06d67)
  • update @types/node version to 22.15.17 in package.json and yarn.lock; add unit and integration tests for logface package (eb4186e)
  • update job names in GitHub Actions workflow and adjust build steps; correct copyright year in LICENSE file; add typeRoots in tsconfig (7c643cb)
  • update version to 0.1.12 in package.json (c36ae26)
  • update version to 0.1.16 in package.json (5697162)

Features

  • add initial smoke tests for npm package installability and importability; include Copilot instructions (3436ad6)
  • update pre-commit and pre-push hooks for improved linting and build process; add Rollup configuration (8ca7caf)