@nextcloud/logger
TypeScript icon, indicating that this package has built-in type declarations

2.7.0 • Public • Published

@nextcloud/logger

Build Status Code coverage npm Documentation

Generic JavaScript logging interface for Nextcloud apps and libraries

Usage

See also API documentation.

import { getLoggerBuilder } from '@nextcloud/logger'

const logger = getLoggerBuilder()
    .setApp('mail')
    .detectUser()
    .build()

logger.debug('hello')
logger.error('this should not have happened', { someContext: 13 })
logger.warn('it\'s just a warning, carry on')

Right now the package uses window.console as log appender and produces the following output

[DEBUG] mail: hello { app: 'mail', uid: 'christoph' }
[ERROR] mail: this should not have happened { app: 'mail', uid: 'christoph', someContext: 13 }
[WARN] mail: it's just a warning, carry on { app: 'mail', uid: 'christoph' }

The logger tries to detect the server configured logging level by default, which can be configured using the loglevel_frontend option in the config.php. In case no logging level was configured or detection failed, the logger will fallback to the warning level.

If the server is set to the debug mode the configured logging level will be set to the debug level.

Any message with a lower level than the configured will not be printed on the console.

You can override the logging level in both cases by setting it manually using the setLogLevel function when building the logger.

Contributing

This repository is maintained using conventional commit messages.

Readme

Keywords

Package Sidebar

Install

npm i @nextcloud/logger

Weekly Downloads

6,293

Version

2.7.0

License

GPL-3.0-or-later

Unpacked Size

75.7 kB

Total Files

16

Last publish

Collaborators

  • susnux
  • pytal
  • gretadoci
  • mejo-
  • artonge
  • max-nextcloud
  • st3iny
  • marcoambrosinii
  • icewind1991
  • skjnldsv
  • christophwurst
  • juliushaertl
  • nickvergessen