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

Provide a way to customise the formatter #1

Closed
jarshwah opened this issue Sep 5, 2016 · 2 comments
Closed

Provide a way to customise the formatter #1

jarshwah opened this issue Sep 5, 2016 · 2 comments

Comments

@jarshwah
Copy link

jarshwah commented Sep 5, 2016

I wanted to add the datetime to the formatting string and couldn't find a good way to do so. Perhaps the init decorator could take a formatter or a function to call instead of basic_config? Anyhow, I've worked around this with monkey patching:

logger = logging.getLogger('myLogger')
handler = click_log.ClickHandler()
formatter = click_log.ColorFormatter('%(asctime)s - %(message)s')
handler.setFormatter(formatter)
click_log.core._default_handler = handler

@click_log.simple_verbosity_option()
@click_log.init(logger)
def cli(args):
    pass

Even this is suboptimal, as the level is forced to lowercase in the handler emit() method.

@untitaker
Copy link
Collaborator

I guess this needs to be done differently (perhaps initialize handler and formatter when init is called). PRs welcome!

@jarshwah
Copy link
Author

I'm no longer personally interested in this. Feel free to reopen (or recreate) if still interested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants