Problem
lib/log.ts exports a mutable module-level logger plus two functions that mutate it globally:
export let logger: ILogger = new InternalLog()
export function replaceLog (externalLog: ILogger) { logger = externalLog }
export function silence () { replaceLog({ /* no-op handlers */ }) }
Neither replaceLog nor silence has a caller anywhere in the shipped source. The SDK injects a logger per instance instead — Api and Driver both take one through their options and keep it — which is why nothing needs the global swap.
They are also not reachable from the package entry point: index.ts re-exports only settings and Rocketchat.
Verified against the consuming app: it does not import the SDK's log module. (Its own logger.silence() call is WatermelonDB's logger, unrelated to this file.)
A process-global, mutable logger that any caller can replace is the kind of API that is hard to remove later once someone does start using it, and impossible to reason about in tests.
Steps to reproduce
- Grep the SDK source for
replaceLog and silence — the only hits are their own definitions
- Note
index.ts does not re-export them
Proposed fix
Delete replaceLog and silence. Keep per-instance logger injection as the only way to control SDK logging.
While in the file: warn forwards to warning on InternalLog and is untested — worth a one-line test if the alias is being kept.
Problem
lib/log.tsexports a mutable module-levelloggerplus two functions that mutate it globally:Neither
replaceLognorsilencehas a caller anywhere in the shipped source. The SDK injects a logger per instance instead —ApiandDriverboth take one through their options and keep it — which is why nothing needs the global swap.They are also not reachable from the package entry point:
index.tsre-exports onlysettingsandRocketchat.Verified against the consuming app: it does not import the SDK's log module. (Its own
logger.silence()call is WatermelonDB's logger, unrelated to this file.)A process-global, mutable logger that any caller can replace is the kind of API that is hard to remove later once someone does start using it, and impossible to reason about in tests.
Steps to reproduce
replaceLogandsilence— the only hits are their own definitionsindex.tsdoes not re-export themProposed fix
Delete
replaceLogandsilence. Keep per-instance logger injection as the only way to control SDK logging.While in the file:
warnforwards towarningonInternalLogand is untested — worth a one-line test if the alias is being kept.