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

use with structlog documentation #6

Open
rachmadaniHaryono opened this issue Jun 15, 2017 · 0 comments
Open

use with structlog documentation #6

rachmadaniHaryono opened this issue Jun 15, 2017 · 0 comments

Comments

@rachmadaniHaryono
Copy link

rachmadaniHaryono commented Jun 15, 2017

is there a way to make it work with https://github.com/hynek/structlog from @hynek?

i am currently can't make it work with simple level configuration.

e1:

import structlog
import click_log

log = structlog.getLogger()

@click.command()
@click_log.simple_verbosity_option()
@click_log.init()
def main():
    structlog.configure(logger_factory=structlog.stdlib.LoggerFactory())
    log.debug('test', v=1)

this work, but it also log the selenium module which my program use.

is there a way to limit the logger to my program only?

e2: still log other module

import logging
import structlog
import click_log

log = structlog.getLogger()

@click.command()
@click_log.simple_verbosity_option()
@click_log.init()
def main():
   logging.basicConfig(level=click_log.get_level())
    structlog.configure(logger_factory=structlog.stdlib.LoggerFactory())
    log.debug('test', v=1)

e3: the working version without click_log

import logging
import structlog

@click.command()
@click.option('-d', '--debug', is_flag=True, help="Enable debug.")
def main(debug):
    if debug:
        logging.basicConfig(level=logging.DEBUG)
    else:
        logging.basicConfig(level=logging.INFO)
    structlog.configure_once(logger_factory=structlog.stdlib.LoggerFactory())
    log = structlog.getLogger()
    log.debug('test', v=1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant