module SimplyGenius::Atmos::Logging
Public Class Methods
clear()
click to toggle source
# File lib/simplygenius/atmos/logging.rb, line 99 def self.clear sio.try(:clear) end
contents()
click to toggle source
# File lib/simplygenius/atmos/logging.rb, line 95 def self.contents sio.try(:sio).try(:to_s) end
init_logger()
click to toggle source
# File lib/simplygenius/atmos/logging.rb, line 54 def self.init_logger return if @initialized @initialized = true ::Logging.format_as :inspect ::Logging.backtrace true ::Logging.color_scheme( 'bright', lines: { debug: :green, info: :default, warn: :yellow, error: :red, fatal: [:white, :on_red] }, date: :blue, logger: :cyan, message: :magenta ) ::Logging.logger.root.level = :info GemLogger.configure do |config| config.default_logger = ::Logging.logger.root config.logger_concern = Logging::GemLoggerConcern end end
setup_logging(level, color, logfile)
click to toggle source
# File lib/simplygenius/atmos/logging.rb, line 103 def self.setup_logging(level, color, logfile) init_logger ::Logging.logger.root.level = level appenders = [] detail_pattern = '[%d] %-5l %c{2} %m\n' plain_pattern = '%m\n' pattern_options = { pattern: plain_pattern } if color pattern_options[:color_scheme] = 'bright' end if self.testing appender = ::Logging.appenders.string_io( 'sio', layout: ::Logging.layouts.pattern(pattern_options) ) appenders << appender else appender = ::Logging.appenders.stdout( 'stdout', layout: ::Logging.layouts.pattern(pattern_options) ) appenders << appender end # Do this after setting up stdout appender so we don't duplicate output # to stdout with our capture if logfile.present? appender = ::Logging.appenders.file( logfile, truncate: true, layout: ::Logging.layouts.pattern(pattern: detail_pattern) ) appenders << appender if ! $stdout.is_a? CaptureStream $stdout = CaptureStream.new("stdout", appender, $stdout) $stderr = CaptureStream.new("stderr", appender, $stderr, :red) silence_warnings { Object.const_set(:STDOUT, $stdout) Object.const_set(:STDERR, $stderr) } end end ::Logging.logger.root.appenders = appenders end
sio()
click to toggle source
# File lib/simplygenius/atmos/logging.rb, line 91 def self.sio ::Logging.logger.root.appenders.find {|a| a.name == 'sio' } end
testing()
click to toggle source
# File lib/simplygenius/atmos/logging.rb, line 83 def self.testing @t end
testing=(t)
click to toggle source
# File lib/simplygenius/atmos/logging.rb, line 87 def self.testing=(t) @t = t end