Module: YiffSpace::Utils::TraceLogger
- Defined in:
- lib/yiffspace/utils/trace_logger.rb
Constant Summary collapse
- COLORS =
{ black: "\e[30m", red: "\e[31m", green: "\e[32m", yellow: "\e[33m", blue: "\e[34m", magenta: "\e[35m", cyan: "\e[36m", white: "\e[37m", reset: "\e[0m", }.freeze
- LEVELS =
noinspection RubyLiteralArrayInspection
{ debug: ["%<cyan>s", "%<blue>s"], error: ["%<red>s", "%<red>s"], info: ["%<cyan>s", "%<blue>s"], warn: ["%<yellow>s", "%<yellow>s"], default: ["%<white>s", "%<white>s"], }.freeze
Class Method Summary collapse
- .colorize(text) ⇒ Object
- .debug ⇒ Object
- .error ⇒ Object
- .format_level(level) ⇒ Object
- .info ⇒ Object
- .warn ⇒ Object
Class Method Details
.colorize(text) ⇒ Object
35 36 37 |
# File 'lib/yiffspace/utils/trace_logger.rb', line 35 def colorize(text, **) format(text, **COLORS, **) end |
.debug ⇒ Object
39 40 41 |
# File 'lib/yiffspace/utils/trace_logger.rb', line 39 def debug(*, **) _log(*, level: :debug, **) end |
.error ⇒ Object
43 44 45 |
# File 'lib/yiffspace/utils/trace_logger.rb', line 43 def error(*, **) _log(*, level: :error, **) end |
.format_level(level) ⇒ Object
29 30 31 32 33 |
# File 'lib/yiffspace/utils/trace_logger.rb', line 29 def format_level(level) level = level.to_sym primary, alternate = LEVELS.fetch(level, LEVELS[:default]) colorize("#{alternate}[%<reset>s#{primary}#{level.to_s.upcase}%<reset>s#{alternate}]%<reset>s") end |
.info ⇒ Object
47 48 49 |
# File 'lib/yiffspace/utils/trace_logger.rb', line 47 def info(*, **) _log(*, level: :info, **) end |
.warn ⇒ Object
51 52 53 |
# File 'lib/yiffspace/utils/trace_logger.rb', line 51 def warn(*, **) _log(*, level: :warn, **) end |