Color
The color field within the logging module expects either a string, or a table with two fields fg (foreground, e.g. text) and bg (background, e.g. a 'highlight'). If just a string is passed, it is used like the fg argument, and bg will default to the console's background.
ANSI color support in Windows Console only became reliable with Windows 10 build 10586 (late 2015) and later; older versions (or very old Windows 7/8) usually show plain white/gray output.
Constants
The following are string fields that are allowed. Their exact HEX color depends on the rendering console, but here are approximate PuTTY colors:
- black
- red
- green
- yellow
- blue
- magenta
- cyan
- white
- bright_black
- bright_red
- bright_green
- bright_yellow
- bright_blue
- bright_magenta
- bright_cyan
- bright_white
- reset
reset
reset is a special 'color', which reverts to what the default is of your console, for example usually white text for foreground, or black background.
Quick tip: white vs bright_white
In many terminals, white renders as silvery gray (~#bbbbbb), while bright_white is pure white (#ffffff).
For regular log text, you should use white as it's more comfortable on the eyes - especially on OLED/AMOLED screens or when reading for long periods. Reserve bright_white for emphasis, errors, or when you need maximum contrast (e.g. white text on a red background).
Examples
local logger = mintmousse.newLogger("foo", "cyan")
local loggerBar = logger:extend("bar", "green")
local loggerFatal = mintmousse.newLogger("FATAL", { fg = "bright_white", bg = "red" })
local loggerInvert = loggerFatal:extend("Inverted", {
fg = "black",
bg = "bright_white",
})