Sha256: 7b34b9ba4db5d8568629addcc164aa27cb425cd436ba17da871372a1a34e3e52
Contents?: true
Size: 1.96 KB
Versions: 4
Compression:
Stored size: 1.96 KB
Contents
module RunLoop # @!visibility private # # This class is required for the XTC. class Logging def self.log_info(logger, message) log_level :info, logger, message end def self.log_debug(logger, message) log_level :debug, logger, message end def self.log_header(logger, message) msg = "\n\e[#{35}m### #{message} ###\e[0m" if logger.respond_to?(:debug) logger.debug(msg) else debug_puts(msg) end end def self.log_level(level, logger, message) level = level.to_sym msg = "#{Time.now} [RunLoop:#{level}]: #{message}" if logger.respond_to?(level) logger.send(level, msg) else debug_puts(msg) end end def self.debug_puts(msg) puts msg if RunLoop::Environment.debug? end end # These are suitable for anything that does not need to be logged on the XTC. # cyan def self.log_unix_cmd(msg) if RunLoop::Environment.debug? puts self.cyan("EXEC: #{msg}") if msg end end # blue def self.log_warn(msg) puts self.blue("WARN: #{msg}") if msg end # magenta def self.log_debug(msg) if RunLoop::Environment.debug? puts self.magenta("DEBUG: #{msg}") if msg end end # red def self.log_error(msg) puts self.red("ERROR: #{msg}") if msg end private # @!visibility private def self.windows_env? RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/ end # @!visibility private def self.colorize(string, color) if self.windows_env? string elsif RunLoop::Environment.xtc? string else "\033[#{color}m#{string}\033[0m" end end # @!visibility private def self.red(string) colorize(string, 31) end # @!visibility private def self.blue(string) colorize(string, 34) end # @!visibility private def self.magenta(string) colorize(string, 35) end # @!visibility private def self.cyan(string) colorize(string, 36) end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
run_loop-1.5.5 | lib/run_loop/logging.rb |
run_loop-1.5.4 | lib/run_loop/logging.rb |
run_loop-1.5.3 | lib/run_loop/logging.rb |
run_loop-1.5.2 | lib/run_loop/logging.rb |