Research/logger improvements#91
Merged
Merged
Conversation
Deep multi-source web research (5 search angles, ~30 sources, 3-vote adversarial verification on every claim — ~15 false claims refuted and dropped). Synthesizes: - Pain points with Winston/Pino/Bunyan (verified against primary GitHub issues + maintainer quotes): Pino's open flush-on-exit race (#1705), Winston memory leak (#1871, fixed v3.6.0), per-module level control declined to core (#206), poor defaults. - What developers want: dynamic runtime reconfiguration (most-requested across trackers), OTel-native log emission, cost-control sampling, edge/cross-runtime. - Innovation: canonical log lines / wide events (Stripe, Honeycomb 'Observability 2.0'), AI moving to the platform layer (bridge not rebuild). Prioritized 9-item roadmap, each rated effort (S/M/L) + impact and cross-checked against logixia's existing v1.10 feature set to separate genuine gaps from already-shipped capabilities. Top bets: Wide Events API, OTLP logs export, dynamic runtime reconfiguration, and marketing the flush-on-exit reliability logixia already has (Pino's #1 unfixed bug). Includes a REFUTED-claims appendix so disproven points (e.g. 'Winston can't do circular refs') don't leak into marketing. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The single most-requested logging feature across the Winston/Pino trackers
(winston#1107, pino#206/#677, nestjs-pino#371) — flip verbosity in a running
process to chase a bug without raising global volume or restarting.
- LogixiaLogger.setNamespaceLevels/patchNamespaceLevels/getNamespaceLevels:
mutate the per-namespace level map at runtime; rebuilds the hot-path caches so
the change applies on the next log call (verified: a db.* child honors a live
level flip).
- registerLevelSignal(logger): cycles the global level on an OS signal
(default SIGUSR2) so one memorizable command ratchets verbosity up/down.
- createLevelControlHandler(logger): Node http / Express-compatible admin
endpoint — GET reads {level, namespaceLevels}, POST sets them, unknown levels
rejected with 400 so a typo can't silently mute logging.
Exported from the package root. Adds 11 tests covering namespace mutation, a
child honoring a live change, signal cycling + dispose, and the HTTP handler
(GET/POST/stream-body/validation/405).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The flagship 2025-26 differentiator: emit ONE dense, structured event per request (Stripe 'canonical log lines' / Honeycomb 'wide events' / Observability 2.0) instead of scattering details across many narrow lines that must be JOINed during an incident. No Node logger ships this first-class. - withWideEvent(logger, init, cb): opens an AsyncLocalStorage scope; addEventFields/ setEventField anywhere in the async tree accumulate onto one event, emitted EXACTLY ONCE when the callback settles — on success OR error (the canonical emit-in-finally guarantee; error/errorMessage added on throw). Auto-attaches durationMs and, when a trace is active, traceId (OTel-friendly). - wideEventMiddleware(logger): Express/Connect middleware that opens the scope per request and emits one canonical line on response finish/close (idempotent across both events) with method/url/ip/statusCode/duration; skip predicate supported. - addEventFields/setEventField/getEventFields are safe no-ops outside a scope so business code calls them unconditionally. Exported from the root. Adds 8 tests: field accumulation, emit-once-on-throw, custom level/message, no-op outside scope, concurrent-scope isolation (no field bleed across requests), and the middleware (finish+close once, skip). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… (R2) logixia already READS the active OTel span (bridge injects traceId/spanId). This closes the loop by EMITTING logs OUT in OTLP/HTTP JSON to a collector, so logs land in any OTLP backend (Loki, OpenObserve, Better Stack, Axiom, Datadog, SigNoz) already correlated with traces. Dependency-free (no @opentelemetry/* — that JS API is still alpha): builds the OTLP/HTTP JSON payload directly, conforming to the OTel logs data model — SeverityNumber mapping (TRACE=1, DEBUG=5, INFO=9, WARN=13, ERROR=17, FATAL=21, custom→INFO), resource attributes (service.name/version, deployment.environment), and TraceId per record. Batches like the cloud transports: whole-batch splice-drain, retry-re-buffer on failure, and close() with bounded drain so no records are lost on shutdown. Exports OtlpLogTransport + toOtelSeverity from the root. Adds 6 tests: severity mapping, OTLP payload shape (resource/scope/logRecords/severity/body/attrs/ traceId), whole-batch drain, failure re-buffer + close drain, and object/bigint serialization. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Cost control is a top-tier 2025-26 theme (Honeycomb 'cost crisis', groundcover adaptive sampling). logixia had static + per-level + trace-consistent sampling + token-bucket; this adds adaptive sampling that captures incidents in full. New SamplingConfig.adaptive: tracks the error rate over a sliding window (default 10s); when it crosses errorRateThreshold (default 5%) with enough samples (minSamples, default 20), the effective sample rate is boosted toward boostRate (default 1.0) so an error spike is captured completely, then relaxes back to the base rate in steady state. Sampler.isBoosting() exposes the current decision. Adds 4 tests: no boost in steady state, boost once the windowed error rate crosses the threshold, no boost before minSamples, and relax as errors age out of the window. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ecycle (R9) Modern Winston/Pino already neutralize cycles to [Circular] (safe-stable- stringify), so merely surviving cycles is no differentiator. safeStringify goes a notch further: - BigInt serialized (string by default, or number) — raw JSON.stringify THROWS on BigInt, silently breaking logging of DB bigint ids. - Optional deterministic key order for stable diffing/hashing. - Optional TRUE decycle: repeated references become round-trippable JSONPath $ref pointers (decycleValue) that retrocycle() reconstructs back into the live shared/circular graph — lossless, unlike the [Circular] tag. - Dates/functions/symbols rendered safely; prototype-pollution keys skipped. Exports safeStringify/decycleValue/retrocycle. Adds 10 tests incl. the decycle→retrocycle round-trip proving the cycle (child.parent === root) and a shared reference (p === q) are reconstructed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ntee (R5) README additions: - Reliability guarantee callout in Graceful shutdown: contrasts logixia's drain-on-close (every transport) + concurrent-signal-guarded shutdown against Pino's still-open flush-on-exit bug (#1705 and the #542/#1774/#1889/#2054 cluster) — the most painful unfixed bug in the most popular Node logger. - New sections + TOC entries: OTLP logs export, Wide events / canonical log lines, Dynamic runtime reconfiguration, Adaptive sampling, Robust serialization. Marks roadmap items 1–6 and 9 as implemented in research/LOGGER-IMPROVEMENTS.md (7 cross-runtime and 8 schema-validation remain as follow-ups). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
size-limit report 📦
|
|
🎉 This issue has been resolved in version 1.11.0. |
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.
Pull Request
📋 Description
What does this PR do?
Why is this change needed?
Related Issues
🔄 Type of Change
🧪 Testing
Test Coverage
Test Details
Manual Testing
📖 Documentation
🔍 Code Quality
📦 Dependencies
🚀 Performance
🔒 Security
📱 Compatibility
🎃 Hacktoberfest
📸 Screenshots/Examples
Before
After
Code Example
🔗 Additional Context
Deployment Notes
Rollback Plan
Future Considerations
✅ Reviewer Checklist
📝 Notes for Reviewers
🙏 Acknowledgments
Thank you for contributing to Logixia! 🚀