Skip to content

Research/logger improvements#91

Merged
webcoderspeed merged 9 commits into
mainfrom
research/logger-improvements
Jun 10, 2026
Merged

Research/logger improvements#91
webcoderspeed merged 9 commits into
mainfrom
research/logger-improvements

Conversation

@webcoderspeed

Copy link
Copy Markdown
Collaborator

Pull Request

📋 Description

What does this PR do?

Why is this change needed?

Related Issues

  • Fixes #
  • Related to #

🔄 Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🧹 Code cleanup/refactoring
  • ⚡ Performance improvement
  • 🧪 Test improvements
  • 🔧 Build/CI improvements

🧪 Testing

Test Coverage

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this change manually

Test Details

# Commands used for testing
npm test
npm run test:coverage
npm run lint

Manual Testing

📖 Documentation

  • Code comments updated
  • README.md updated
  • API documentation updated
  • Examples updated
  • CHANGELOG.md updated (for significant changes)

🔍 Code Quality

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings or errors
  • I have run the linter and fixed any issues

📦 Dependencies

  • No new dependencies added
  • New dependencies are justified and documented
  • Dependencies are pinned to specific versions
  • Security implications have been considered

🚀 Performance

  • No performance impact
  • Performance impact is minimal and justified
  • Performance improvements included
  • Benchmarks provided (if applicable)

🔒 Security

  • No security implications
  • Security implications have been considered and addressed
  • No sensitive data exposed
  • Input validation added where necessary

📱 Compatibility

  • Node.js versions:
  • Operating Systems:
  • Breaking changes documented
  • Migration guide provided (if needed)

🎃 Hacktoberfest

  • This is a Hacktoberfest contribution
  • I have read and followed the contribution guidelines
  • This PR provides meaningful value (not spam)
  • I understand the project's goals and scope

📸 Screenshots/Examples

Before

After

Code Example

// Example of how to use the new feature
import { Logixia } from 'logixia';

const logger = new Logixia({
  // example configuration
});

// example usage

🔗 Additional Context

Deployment Notes

Rollback Plan

Future Considerations

✅ Reviewer Checklist

  • Code quality meets project standards
  • Tests are comprehensive and pass
  • Documentation is updated and clear
  • Breaking changes are properly documented
  • Security implications reviewed
  • Performance impact acceptable
  • Ready for merge

📝 Notes for Reviewers

🙏 Acknowledgments


Thank you for contributing to Logixia! 🚀

webcoderspeed and others added 8 commits June 11, 2026 02:07
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>
@github-actions

Copy link
Copy Markdown

size-limit report 📦

Path Size
ESM (gzipped) 15.05 KB (+47.27% 🔺)
CJS (gzipped) 15.12 KB (+47.73% 🔺)

@webcoderspeed webcoderspeed merged commit 6ad3d48 into main Jun 10, 2026
@github-actions

Copy link
Copy Markdown

🎉 This issue has been resolved in version 1.11.0.
Install it: npm install logixia@1.11.0

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