Logger
formatterThe default formatter decorates the messages with severity labels and colors.
logger :: DefaultFormatter :: no_color=
Do not decorate messages with colorslogger $ DefaultFormatter :: SELF
Type of this instance, automatically specialized in every classcore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
logger :: Formatter :: defaultinit
core :: Object :: defaultinit
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
logger :: DefaultFormatter :: no_color=
Do not decorate messages with colorscore :: Object :: output_class_name
Display class name on stdout (debug only).
# Default `Logger` formatter
#
# The default formatter decorates the messages with severity labels and colors.
class DefaultFormatter
super Formatter
# Do not decorate messages with colors
#
# ~~~
# var formatter = new DefaultFormatter(no_color = true)
# assert formatter.format(error_level, "My message.") == "Error: My message."
# ~~~
var no_color = false is optional, writable
redef fun format(level, message) do
var string = message.write_to_string
if level == fatal_level then
string = "Fatal: {string}"
else if level == error_level then
string = "Error: {string}"
else if level == warn_level then
string = "Warning: {string}"
else if level == info_level then
string = "Info: {string}"
else if level == debug_level then
string = "Debug: {string}"
end
if no_color then return string
if level == fatal_level then
return string.red
else if level == error_level then
return string.red
else if level == warn_level then
return string.yellow
else if level == info_level then
return string.purple
else if level == debug_level then
return string.blue
end
return string
end
end
lib/logger/logger.nit:322,1--367,3