log.ts 849 B

123456789101112131415161718192021222324252627
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import log from 'loglevel'
  3. // Use INFO as default log level rather than WARN.
  4. log.setDefaultLevel(log.levels.INFO)
  5. // Register window.setLogLevel to allow for manual changing for debugging.
  6. window.setLogLevel = (level: LogLevel, persistent = true): void => {
  7. return log.setLevel(level, persistent)
  8. }
  9. // Usage:
  10. // // Logging in code:
  11. // import log from '#shared/util/log.ts'
  12. // log.error('error message', ...)
  13. // log.warn('warn message', ...)
  14. // log.info('info message', ...)
  15. // log.debug('debug message', ...)
  16. // log.trace('trace message', ...)
  17. // // Manual changing of log level via JS console for debugging purposes:
  18. // setLogLevel(log.levels.TRACE, false) // temporary
  19. // setLogLevel(log.levels.TRACE) // persistent via local storage
  20. export default log