-
Notifications
You must be signed in to change notification settings - Fork 24
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
how to use click_log.basic_config() to configure format? #13
Comments
What are you missing from the docs? They contain an example where it's used after all. |
This was more related to the In my usecase I'd like to keep the coloring depending on log level as prefix, but change the rest of the printed text to include the loggers name, date etc, without having to duplicate most of the color handling in ColorFormatter. What's your opinion on changing |
You might want to subclass the formatter, but I'll accept a PR as long as it doesn't get too complicated
…On 21 February 2018 23:51:48 GMT+01:00, Florian Klink ***@***.***> wrote:
This was more related to the `format` parameter that
`logging.basic_config(format=…)` exposes, but
`click_log.basic_config()` currently doesn't.
In my usecase I'd like to keep the coloring depending on log level as
prefix, but change the rest of the printed text to include the loggers
name, date etc, without having to duplicate most of the color handling
in ColorFormatter.
What's your opinion on changing `click_log.basic_config`s signature to
`basic_config(logger=None, format='%(message)s')`, and adding needed
wiring to ColorFormatter? If somebody doesn't want the color
formatting, he could simply use another Formatter, but configuring the
rest of the format string inside ColorFormatter should be made
possible.
--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
#13 (comment)
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
|
@untitaker I had a look into it. We already subclass However, honoring a passed In addition, we'd only be able to color the message as a whole (by calling So what's your opinion on it? I'd really like to see support for the |
You're suggesting this:
I would suggest:
Feel free to include a formatter you'd like (separate from ColorFormatter) in the PR too, but also with a default format string so I can understand what you're doing with it. My usecase for the current logger is: simple command line applications where the output is usually not written to a file. |
👋 hello all, happened across this issue because I wanted my nicely-formatted logs to have fancy colors. This is a bit of a hack but it does work:
A couple notes:
|
The docs are not really verbose about how to use
click_log.basic_config()
.Most intuitive way would be for it to have the same usage as here.
I wanted it to show the
__name__
I pass intologging.getLogger(__name__)
, and preserve color output.The text was updated successfully, but these errors were encountered: