You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(various): Apply debug guard to logger everywhere (#4698)
This applies the `isDebugBuild()` guard (which allows logging code to be stripped when creating minified bundles) to a number of aspects of the logger:
- All calls to the logger now have the guard. While it's true that not all log statements appear in spots which currently have any chance of making it into a bundle, applying the guard universally reduces cognitive load for both folks reading and writing our code, and future-proofs (or, perhaps more accurately, new-bundling-situation-proofs) all of our logging.
- The `Sentry.init()` option `debug` now only enables the logger if we're in a debug build. This allows us to remove any reference to the logger in non-debug builds, making it able to be dropped from the code. A warning message has also been added to non-debug builds, because someone using `debug` is presumably doing so because they actually do want logging.
- The `logger` singleton is only attached to `global.__SENTRY__` if we're in a debug build. This makes `logger.ts` side-effect-free in non-debug builds, allowing it to be treeshaken freely.
Note that because the return value of `isDebugBuild()` is always `true` (absent intervention by a bundler), it's safe to use everywhere without changing any current behavior.
Finally, all preexisting `if`-block versions of the check are converted to short-circuit versions, for consistency and concision.
0 commit comments