Skip to content

feat(logger): add configurable logger to control console output#73

Merged
seansica merged 1 commit intonextfrom
feat/enable-console-log-controls
May 6, 2026
Merged

feat(logger): add configurable logger to control console output#73
seansica merged 1 commit intonextfrom
feat/enable-console-log-controls

Conversation

@seansica
Copy link
Copy Markdown
Contributor

@seansica seansica commented May 6, 2026

Summary

  • Adds a configurable logger (src/logger.ts) with levels debug | info | warn | error | silent, defaulting to warn.
  • Replaces the four console.log/console.warn calls in registerDataSource, parseStixBundle, and the relationship deprecation refinement with logger.* calls so they can be silenced or redirected.
  • Exposes configureLogger, resetLogger, and the LogLevel/LogHandler/LoggerConfig types from the package root. Reads ADM_LOG_LEVEL from the environment when no explicit configuration is set.

Why

Consumers parsing many bundles in a row (especially through relaxed mode, where the deprecation warning fires for every x-mitre-data-component → detects → attack-pattern relationship) had no way to suppress the noise. This is both a fix (output is now silenceable) and a feature (level + handler are configurable, including a custom handler for routing to structured loggers like pino/winston).

Behavior change

The default level is warn, which keeps the previously-visible deprecation and relaxed-mode validation warnings while suppressing the four informational console.log lines (Retrieved data, Parsed data., the count, Initialized data model.). Pass level: 'info' to restore the prior verbose output.

Documentation

  • New "Logging" section in USAGE.md.
  • New how-to guide at docusaurus/docs/how-to-guides/configure-logging.mdx, registered in the sidebar.

Replaces direct console.log/console.warn calls in registerDataSource,
parseStixBundle, and the relationship deprecation refinement with a
shared logger module. Defaults to the  level so informational
messages emitted during data source registration are no longer printed
unless opted into.

Levels: debug, info, warn, error, silent. Configure via
configureLogger({ level, handler }) or the ADM_LOG_LEVEL env var.
A custom LogHandler can be supplied to forward messages to an external
logging system. resetLogger() restores defaults.

Fixes the noise problem when parsing many bundles in a row, and
introduces logger configuration as a public feature.
@seansica seansica self-assigned this May 6, 2026
@seansica seansica merged commit 56ce9c2 into next May 6, 2026
4 checks passed
@seansica seansica deleted the feat/enable-console-log-controls branch May 6, 2026 17:48
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

🎉 This PR is included in version 4.11.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant