Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Handlers): allow for configuration of log outputs #7

Open
beneboy opened this issue Sep 3, 2019 · 0 comments
Open

feat(Handlers): allow for configuration of log outputs #7

beneboy opened this issue Sep 3, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@beneboy
Copy link
Contributor

beneboy commented Sep 3, 2019

Logga has so far been built just for capturing errors, not outputting them anywhere. Since existing logging solutions aren't configurable with files in a nice way, we could add this functionality to logga for configurable output.

{
    "level": "debug",
    "format": "${time} ${levelname} ${message}"
    "handlers": [
        {
            "type": "file",
            "path": "/path/to/file",
            "level": "warning"
        },
        {
            "type": "file",
            "path": "/errors/only",
            "level": "error"
        }
        {
            "type": "console",
            "level": "debug",
            "format": "${levelEmoji} ${levelName} ${time} ${message} ${trace}"
        },
        {
            "type": "syslog"
            "level": "error"
        }
    ],
    "loggas": {
        "stencila.encoda": {
            "handlers": []
        },
        "stencila.schema": {
            "level": "error",
            "handlers": [
                {
                "type": "console",
                "level": "debug"
                }
            ]
        }
    }
}

The message level must exceed both the handler level, global level and (if in a module) the module level to be logged somewhere.

If a logging module name is not found in the loggas dictionary it will fall back to the defaults.

Some examples:

log = getLogger('stencila.thema')
log.debug('some message')

Would log only to the console with a 🚨 emoji.

log.error('Some error')

Would log to /errors/only, /path/to/file, console and syslog. The syslog and file formats would be the global format.

encLogger = getLogger('stencila.encoda')
log.critical('some message')

Would not log anywhere as stencila.encoda has no handlers.

encLogger = getLogger('stencila.schema')
log.debug('some debug message')

Would not log anywhere because the stencila.schema log level is error so handlers can not override it.

There could be a standard list of default locations to look for a configuration file in, or passed in from the command line. (logga.json in the project dir, ~/.logga.json, /etc/logga.json etc)

@nokome nokome added the enhancement New feature or request label Jan 19, 2020
@nokome nokome changed the title Logga output configuration feat(Handlers): allow for configuration of log outputs Jan 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants