Class: Rookout::Logger

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/rookout/logger.rb

Defined Under Namespace

Classes: LogRecord

Constant Summary collapse

LOG_LEVELS =
[:DEBUG, :INFO, :WARNING, :ERROR].freeze

Instance Method Summary collapse

Constructor Details

#initializeLogger

Returns a new instance of Logger.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rookout/logger.rb', line 13

def initialize
  # Detect unit tests
  if (Config.debug ||
      $PROGRAM_NAME.end_with?("minitest_runner.rb") ||
      $PROGRAM_NAME.end_with?("tunit_or_minitest_in_folder_runner.rb")) &&
     Dir.pwd.end_with?("ruby-sdk")
    Config.logger_log_level = :DEBUG
    Config.logger_log_to_stderr = true
  end

  @verbosity = LOG_LEVELS.index(Config.logger_log_level) || LOG_LEVELS.index(:INFO)

  @output = nil
  @handlers = []
  build_handlers
end

Instance Method Details

#debug(message, *args) ⇒ Object



38
39
40
# File 'lib/rookout/logger.rb', line 38

def debug message, *args
  log :DEBUG, message, args
end

#error(message, *args) ⇒ Object



50
51
52
# File 'lib/rookout/logger.rb', line 50

def error message, *args
  log :ERROR, message, args
end

#exception(message, exc) ⇒ Object



54
55
56
# File 'lib/rookout/logger.rb', line 54

def exception message, exc
  error message, exc
end

#info(message, *args) ⇒ Object



42
43
44
# File 'lib/rookout/logger.rb', line 42

def info message, *args
  log :INFO, message, args
end

#register_output(output) ⇒ Object



30
31
32
# File 'lib/rookout/logger.rb', line 30

def register_output output
  @output = output
end

#remove_output(_output) ⇒ Object



34
35
36
# File 'lib/rookout/logger.rb', line 34

def remove_output _output
  @output = nil
end

#warning(message, *args) ⇒ Object



46
47
48
# File 'lib/rookout/logger.rb', line 46

def warning message, *args
  log :WARNING, message, args
end