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 color red for error messages #304

Closed
rEnr3n opened this issue Jun 9, 2019 · 3 comments
Closed

Use color red for error messages #304

rEnr3n opened this issue Jun 9, 2019 · 3 comments

Comments

@rEnr3n
Copy link

rEnr3n commented Jun 9, 2019

For easier spotting of errors.

@rEnr3n
Copy link
Author

rEnr3n commented Jun 10, 2019

I just noticed the messages I get are warnings, not errors. Maybe you can include them or give them a different color (e.g. yellow).

[downloader.http][warning] HTTPSConnectionPool(host='i.imgur.com', port=443): Read timed out. (1/99999999999999999999999999999999999999999999999)
[downloader.http][warning] HTTPSConnectionPool(host='i.imgur.com', port=443): Max retries exceeded with url: /Gci77ma.jpg (Caused by ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x7fe091916cc0>, 'Connection to i.imgur.com timed out. (connect timeout=30)')) (1/99999999999999999999999999999999999999999999999)

@mikf
Copy link
Owner

mikf commented Jun 10, 2019

One way you can do this right now, albeit for all logging messages, is to specify a custom log message format string with ANSI color codes in them, given your terminal understands ANSI codes. (And while there are other ways of implementing colored console output, I'm not planning on adding support for anything other than ANSI codes)

A minimal config file that uses bold red for all logging messages:

{
    "output":
    {
        "log": "\u001b[1;31m[{name}][{levelname}] {message}\u001b[0m"
    }
}

mikf added a commit that referenced this issue Jun 26, 2019
supports custom log message formats for each loglevel and, by
extension, custom ANSI codes and colors for errors and warnings

(#304)
@mikf
Copy link
Owner

mikf commented Jul 1, 2019

You can now specify a log message format string for each log level. For example:

{
    "output":
    {
        "log": {
            "format": {
                "debug"  : "\u001b[0;37m[{name}][{levelname}] {message}\u001b[0m",
                "info"   : "\u001b[1;37m[{name}][{levelname}] {message}\u001b[0m",
                "warning": "\u001b[1;33m[{name}][{levelname}] {message}\u001b[0m",
                "error"  : "\u001b[1;31m[{name}][{levelname}] {message}\u001b[0m"
            }
        }
    }
}

will produce red errors, yellow/orange warnings, bold white infos, and grey debug messages.

And here is a list of possible ANSI color codes: https://bluesock.org/~willkg/dev/ansi.html#ansicodes (replace \e with \u001b to make them JSON-compatible)

@mikf mikf closed this as completed Jul 1, 2019
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