Class: Raykit::Logger
- Inherits:
-
Object
- Object
- Raykit::Logger
- Defined in:
- lib/raykit/logger.rb
Class Method Summary collapse
- .console_logger ⇒ Object
- .default ⇒ Object
- .file_logger ⇒ Object
-
.strip_ansi_codes(str) ⇒ Object
Strips ANSI color codes.
Instance Method Summary collapse
- #debug(message) ⇒ Object
- #error(message) ⇒ Object
- #fatal(message) ⇒ Object
- #info(message) ⇒ Object
-
#initialize(logger_array) ⇒ Logger
constructor
A new instance of Logger.
- #level=(level) ⇒ Object
- #warn(message) ⇒ Object
Constructor Details
#initialize(logger_array) ⇒ Logger
Returns a new instance of Logger.
6 7 8 9 |
# File 'lib/raykit/logger.rb', line 6 def initialize(logger_array) @logger_array = logger_array #@loggerB = loggerB end |
Class Method Details
.console_logger ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/raykit/logger.rb', line 55 def self.console_logger console_logger = ::Logger.new(STDOUT) console_logger.formatter = proc do |_severity, _datetime, _progname, msg| "#{Raykit::Symbols::get_severity_symbol(_severity)} #{msg}\n" end console_logger end |
.default ⇒ Object
51 52 53 |
# File 'lib/raykit/logger.rb', line 51 def self.default Raykit::Logger.new([Raykit::Logger::console_logger]) #, Raykit::Logger::file_logger]) end |
.file_logger ⇒ Object
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/raykit/logger.rb', line 63 def self.file_logger log_dir = Environment::log_dir FileUtils.mkdir_p(log_dir) if (!Dir.exist?(log_dir)) #FileUtils.mkdir("log") if (!Dir.exist?("log")) file_logger = ::Logger.new(File.new(LOG_FILENAME, "w")) file_logger.formatter = proc do |_severity, _datetime, _progname, msg| "#{strip_ansi_codes(msg)}\n" end file_logger end |
.strip_ansi_codes(str) ⇒ Object
Strips ANSI color codes
47 48 49 |
# File 'lib/raykit/logger.rb', line 47 def self.strip_ansi_codes(str) # Strips ANSI color codes str.gsub(/\e\[[0-9;]*m/, "") end |
Instance Method Details
#debug(message) ⇒ Object
17 18 19 20 21 |
# File 'lib/raykit/logger.rb', line 17 def debug() @logger_array.each do |logger| logger.debug() end end |
#error(message) ⇒ Object
35 36 37 38 39 |
# File 'lib/raykit/logger.rb', line 35 def error() @logger_array.each do |logger| logger.error() end end |
#fatal(message) ⇒ Object
41 42 43 44 45 |
# File 'lib/raykit/logger.rb', line 41 def fatal() @logger_array.each do |logger| logger.fatal() end end |
#info(message) ⇒ Object
23 24 25 26 27 |
# File 'lib/raykit/logger.rb', line 23 def info() @logger_array.each do |logger| logger.info() end end |
#level=(level) ⇒ Object
11 12 13 14 15 |
# File 'lib/raykit/logger.rb', line 11 def level=(level) @logger_array.each do |logger| logger.level = level end end |
#warn(message) ⇒ Object
29 30 31 32 33 |
# File 'lib/raykit/logger.rb', line 29 def warn() @logger_array.each do |logger| logger.warn() end end |