feat(logger): add configurable logger to control console output#73
Merged
feat(logger): add configurable logger to control console output#73
Conversation
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.
|
🎉 This PR is included in version 4.11.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/logger.ts) with levelsdebug | info | warn | error | silent, defaulting towarn.console.log/console.warncalls inregisterDataSource,parseStixBundle, and the relationship deprecation refinement withlogger.*calls so they can be silenced or redirected.configureLogger,resetLogger, and theLogLevel/LogHandler/LoggerConfigtypes from the package root. ReadsADM_LOG_LEVELfrom the environment when no explicit configuration is set.Why
Consumers parsing many bundles in a row (especially through
relaxedmode, where the deprecation warning fires for everyx-mitre-data-component → detects → attack-patternrelationship) 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 andrelaxed-mode validation warnings while suppressing the four informationalconsole.loglines (Retrieved data,Parsed data., the count,Initialized data model.). Passlevel: 'info'to restore the prior verbose output.Documentation
USAGE.md.docusaurus/docs/how-to-guides/configure-logging.mdx, registered in the sidebar.