Module: Telemetry::Logger::ConsoleLogger::Defaults

Defined in:
lib/telemetry/logger/console_logger.rb

Class Method Summary collapse

Class Method Details

.activationObject



85
86
87
88
89
90
# File 'lib/telemetry/logger/console_logger.rb', line 85

def self.activation
  activation = ENV['LOGGER']
  return activation if activation

  'on'
end

.colorObject



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/telemetry/logger/console_logger.rb', line 92

def self.color
  color = ENV['LOG_COLOR']

  # CONSOLE_COLOR is obsolete. It is here for backwards compatibility
  if color.nil?
    color = ENV['CONSOLE_COLOR']

    unless color.nil?
      puts '*** WARNING: The CONSOLE_COLOR environment variable is obsolete. Use LOG_COLOR instead. Support for CONSOLE_COLOR will be discontinued.'
    end
  end

  return color if color

  if device.tty?
    'on'
  else
    'off'
  end
end

.deviceObject



71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/telemetry/logger/console_logger.rb', line 71

def self.device
  setting = ENV['CONSOLE_DEVICE']
  device = nil
  if setting && !['stderr', 'stdout'].include?(setting)
    raise "The CONSOLE_DEVICE should be either 'stderr' (default) or 'stdout'"
  elsif setting
    device = setting == 'stderr' ? STDERR : STDOUT
  else
    device = STDERR
  end
  device.sync = true
  device
end

.levelObject



64
65
66
67
68
69
# File 'lib/telemetry/logger/console_logger.rb', line 64

def self.level
  level = ENV['LOG_LEVEL']
  return level.to_sym if level

  :info
end