lib/telemetry/logger/methods.rb in telemetry-logger-0.1.0 vs lib/telemetry/logger/methods.rb in telemetry-logger-0.1.1
- old
+ new
@@ -1,5 +1,7 @@
+require 'rainbow'
+
module Telemetry
module Logger
module Methods
def colorize
@colorize ||= if opts[:logfile].is_a?(String)
@@ -13,48 +15,48 @@
def debug(message = nil)
return unless log.level < 1
message = yield if message.nil? && block_given?
- message = Rainbow(message).blue if @color
+ message = Rainbow(message).blue if colorize
log.debug(message)
end
def info(message = nil)
return unless log.level < 2
message = yield if message.nil? && block_given?
- message = Rainbow(message).green if @color
+ message = Rainbow(message).green if colorize
log.info(message)
end
def warn(message = nil)
return unless log.level < 3
message = yield if message.nil? && block_given?
- message = Rainbow(message).yellow if @color
+ message = Rainbow(message).yellow if colorize
log.warn(message)
end
def error(message = nil)
return unless log.level < 4
message = yield if message.nil? && block_given?
- message = Rainbow(message).red if @color
+ message = Rainbow(message).red if colorize
log.error(message)
end
def fatal(message = nil)
return unless log.level < 5
message = yield if message.nil? && block_given?
- message = Rainbow(message).darkred if @color
+ message = Rainbow(message).darkred if colorize
log.fatal(message)
end
def unknown(message = nil)
message = yield if message.nil? && block_given?
- message = Rainbow(message).purple if @color
+ message = Rainbow(message).purple if colorize
log.unknown(message)
end
def thread(kvl: false, **_opts)
if kvl