Skip to content

Logger implementation#71

Open
itzmanish wants to merge 3 commits into
video-dev:mainfrom
itzmanish:feat/logger
Open

Logger implementation#71
itzmanish wants to merge 3 commits into
video-dev:mainfrom
itzmanish:feat/logger

Conversation

@itzmanish
Copy link
Copy Markdown
Contributor

No description provided.

itzmanish and others added 3 commits March 17, 2026 19:26
Add lib/common/logger.ts — a zero-dependency, single-dispatcher logger:

- LogLevel type: "*" | "trace" | "debug" | "info" | "warn" | "error" | "none"
- Logger interface: optional level() + per-level methods; library calls level()
  before every emit so consumers own their own filtering
- Default: built-in console logger at "error" level
- setGlobalLogger(logger) / setGlobalLogger(undefined) to install or restore
- createConsoleLogger(level) helper for consumers who just want a different
  verbosity on the built-in output
- notifyLoggerLevelChanged() to re-sync workers when level changes at runtime
- getLogger() — called once at module level with no args; derives scope
  automatically from the call stack (e.g. "transport/connection"), returns a
  frozen ScopedLogger that closes over scope and calls the single dispatcher
- Worker propagation: getWorkerLogger() / getWorkletLogger() for Web Worker
  and AudioWorklet; setWorkerLogLevel() / setWorkletLogLevel() wired to
  ToWorker.logLevel and worklet message.logLevel;
  installWorkerLogReceiver() / installWorkletLogReceiver() on the main thread
  route FromWorker.log records into the global logger; Backend sends initial
  log level and re-syncs on every setGlobalLogger call via onLoggerLevelChange()
- All output prefixed with "[MoQJS]" and "[<scope>]" as leading args so
  consumers can filter or format independently

Migrate all console.* call sites in lib/** to scoped loggers:
- error: caught failures, decoder/encoder errors, fatal stream errors
- warn:  dropped chunks/frames, missing elements, unsupported APIs
- debug: lifecycle transitions, setup details, subscribe/publish state
- trace: per-object/per-frame chatty logs, protocol payload dumps

Re-export public logger API (setGlobalLogger, getGlobalLogger,
createConsoleLogger, notifyLoggerLevelChanged, Logger, LogLevel) from all
three entry points so consumers of any bundle variant can configure logging.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant