Skip to content

Allow debug logging that can be enabled / disabled #894

@max-nextcloud

Description

@max-nextcloud

Use case

In the text app we sometimes need very detailed logging. Think several lines of debug logging per keystroke.

Currently we have some logging statements commented out that we enable then.
But if they were always enabled that would spam the logs too much.

Would be nice to have this build into the logger.

Possible interface

// ExampleService.ts in the text app
const logger = getLoggerBuilder().setApp('text')... .build()
const debug = logger.createOptionalDebugLogger('ExampleService')
...
service.on('update', (update) => debug('received update', { update }))

Usage in the Browser console:

OCA.Logger.debug.text.ExampleService = true

Populating OCA.Logger.debug when the optional debug logger is created would enable auto completion on the browser command line.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions