Skip to content

refactor: introduce shared logger and migrate console.* across packages#3621

Open
theguriev wants to merge 1 commit into
superdoc-dev:mainfrom
theguriev:chore/logger-abstraction
Open

refactor: introduce shared logger and migrate console.* across packages#3621
theguriev wants to merge 1 commit into
superdoc-dev:mainfrom
theguriev:chore/logger-abstraction

Conversation

@theguriev
Copy link
Copy Markdown

Adds a canonical, level-gated, silenceable logger at @superdoc/common/logger and replaces ~620 raw console.* calls in shipped package source with it, so embedding SuperDoc no longer spams the host console and output is filterable and redirectable.

  • New @superdoc/common/logger: levels (silent/error/warn/info/debug, default warn), namespaces + child(), configurable global sink, env override (SUPERDOC_LOG_LEVEL). Console.log statements map to log.debug (silent by default); warn/error stay visible.
  • Migrated super-editor (~370), superdoc (~50), layout-engine layout-bridge/painters-dom/layout-engine/measuring (~99).
  • Consolidated existing ad-hoc loggers onto the canonical one: super-validator logger and collaboration-yjs internal-logger become thin adapters (collaboration-yjs gains @superdoc/common dep). The deprecated @superdoc-dev/ai package keeps its own logger.
  • eslint no-console rule for package src (logger module, deprecated ai logger and a zero-dep env-gated url-validation warning are exempt).
  • Updated console-spy test assertions to the namespaced output shape.

Verified: full tsc -b, no-console clean repo-wide, and vitest green for super-editor (15787), superdoc (1123), layout-engine painters-dom (1179), layout-bridge (1281), measuring-dom (349), collaboration-yjs (42). The bun-test suites (@superdoc/common, layout-engine core) were not run locally (no bun) but compile clean and contain no console-spy assertions.

Adds a canonical, level-gated, silenceable logger at @superdoc/common/logger
and replaces ~620 raw console.* calls in shipped package source with it, so
embedding SuperDoc no longer spams the host console and output is filterable
and redirectable.

- New @superdoc/common/logger: levels (silent/error/warn/info/debug, default
  warn), namespaces + child(), configurable global sink, env override
  (SUPERDOC_LOG_LEVEL). Console.log statements map to log.debug (silent by
  default); warn/error stay visible.
- Migrated super-editor (~370), superdoc (~50), layout-engine
  layout-bridge/painters-dom/layout-engine/measuring (~99).
- Consolidated existing ad-hoc loggers onto the canonical one:
  super-validator logger and collaboration-yjs internal-logger become thin
  adapters (collaboration-yjs gains @superdoc/common dep). The deprecated
  @superdoc-dev/ai package keeps its own logger.
- eslint no-console rule for package src (logger module, deprecated ai logger
  and a zero-dep env-gated url-validation warning are exempt).
- Updated console-spy test assertions to the namespaced output shape.

Verified: full tsc -b, no-console clean repo-wide, and vitest green for
super-editor (15787), superdoc (1123), layout-engine painters-dom (1179),
layout-bridge (1281), measuring-dom (349), collaboration-yjs (42). The
bun-test suites (@superdoc/common, layout-engine core) were not run locally
(no bun) but compile clean and contain no console-spy assertions.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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