@stnd/log
Centralized logging for the Standard framework. Colored, leveled, scoped terminal output.
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);
Banner
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):
- Explicit option —
Log({ level: ‘DEBUG’ }) - Global config —
globalThis.__STANDARD_CONFIG__.logLevel - Environment variable —
STND_LOG_LEVELorLOG_LEVEL - Default —
INFOin development,WARNin 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
License
MIT