david-massey / yarl

MIT License
2 stars 0 forks source link

Add per message coloring #1

Open adelyte-chris opened 5 years ago

adelyte-chris commented 5 years ago

Is it possible to support per-message coloring? I would like to color important messages with a bright color and less important messages with a dim color.

Example

logger.debug "important message", color: :bright_cyan
logger.debug "less important message", color: :cyan
david-massey commented 5 years ago

So you're looking for the header to change color per message or the message body to change color per message?

If the latter, the SPAM level is already a dimmed color (dark gray | "bright_black") by default. If this does not work, I can add per-message body colors.

If the former, a simple solution would be to have two loggers -- that way you don't need to specify colors per-message.

Example

important = YARL.new color: :bright_cyan
less_important = YARL.new color: :cyan

important.debug 'important message'
less_important.debug 'less important message'
less_important.spam 'pretty unimportant message'

Of course if you'd rather have this all in one logger, I can add an optional, per-message header color change.