stnd.buildSTANDARD MANUAL2026-07-15

@stnd/log

@stnd/log

Centralized logging for the Standard framework. Colored, leveled, scoped terminal output.

ELI5

console.log with a name tag and a volume knob. Every @stnd/* package’s terminal output goes through this, so it’s consistently colored and can be turned down (STND_LOG_LEVEL=ERROR) without touching code.

Use it:

import Log from "@stnd/log";
const log = Log({ scope: "MyModule" });
log.info("Doing the thing");

Install

npm install @stnd/log

Usage

Static methods (quick & easy)

import Log from "@stnd/log";

Log.info("Server started on port 3000");
Log.success("Build complete");
Log.warn("Deprecated API usage");
Log.error("Connection failed");
Log.debug("Raw payload:", data);

Static methods with scope

When multiple arguments are passed, the first is treated as a scope:

Log.info("Markdown", "Processing 42 files...");
Log.warn("Build", "Missing config, using defaults");
Log.error("Auth", "Token expired");

Instance-based (persistent scope)

Create a scoped instance when logging repeatedly from the same module:

const log = Log({ scope: "Markdown" });

log.info("Processing files...");
log.success("Compiled 42 files");
log.warn("Missing frontmatter in post.md");
log.error("Failed to parse YAML", error);
log.debug("Raw block data:", blockData);
Log.banner("0.18.0");
Log.banner("0.18.0", "https://custom.url");
Log.bannerSuccess("Build complete!");

Fatal (throws)

log.fatal("Missing required config"); // logs then throws Error

Log levels

Level Value Description
DEBUG 0 Development debugging
INFO 1 General information (default in dev)
WARN 2 Warnings (default in production)
ERROR 3 Errors only
NONE 4 Silent

Setting the level

Priority order (highest wins):

  1. Explicit option — Log({ level: 'DEBUG' })
  2. Global config — globalThis.__STANDARD_CONFIG__.logLevel
  3. Environment variable — STND_LOG_LEVEL or LOG_LEVEL
  4. Default — INFO in development, WARN in production
// Instance with explicit level
const log = Log({ level: "DEBUG", scope: "Loader" });

// Or via environment
// STND_LOG_LEVEL=DEBUG node build.js

Accessing levels programmatically

Log.LEVELS.DEBUG; // 0
Log.LEVELS.INFO; // 1
Log.LEVELS.WARN; // 2
Log.LEVELS.ERROR; // 3
Log.LEVELS.NONE; // 4

Notes / Observations

(jot down anything noticed here — quirks, gotchas, ideas)

Todo

  • [ ] Nothing tracked yet.

License

MIT