Skip to content

Feature request - Colored console text #16

Open
@rcurrier666

Description

@rcurrier666

With several of my apps I leave the log lines visible in a console window continuously. I'd like to be able to differentiate warnings, errors, and criticals from the other log lines at a glance by color coding the output based on the log level. This may not be of general interest, but someone else might find it useful.

I'm thinking of adding a new function, SetColors(), that takes an 8 item array where each item is a color to use for that log level. It would default to all NONE so the behavior would be as it is now. The writer would output the proper control string to set that color at the front of the log line and the control string to reset back to "none" at the end. A NONE value would not write anything extra. Overhead should be small, a couple of if statements, a control string lookup, and writing an extra 9 bytes. Obviously, I hope, this would only be for console logging.

I'll be prototyping this tomorrow (it's bedtime now). If this sounds like something that you would accept, I'll put in a pull request for you to look at. Your log4go repo seems to be the only fork that is being actively maintained so I'd rather add it to your's rather than fork it again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions