Module: Codacy::Configuration

Defined in:
lib/codacy/configuration.rb

Defined Under Namespace

Classes: MultiLogger

Class Method Summary collapse

Class Method Details

.loggerObject



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/codacy/configuration.rb', line 7

def self.logger
  logger_info = logger_to_stdout
  logger_info.level = Logger::INFO

  logger_debug = ENV["DEBUG_STDOUT"] ? logger_to_stdout : logger_to_file
  logger_debug.level = Logger::DEBUG

  log = MultiLogger.new(logger_info, logger_debug)

  log
end

.logger_to_fileObject



23
24
25
26
27
# File 'lib/codacy/configuration.rb', line 23

def self.logger_to_file
  log_filename = self.temp_dir + 'codacy-coverage_' + Date.today.to_s + '.log'
  log_file = File.open(log_filename, 'a')
  Logger.new(log_file)
end

.logger_to_stdoutObject



19
20
21
# File 'lib/codacy/configuration.rb', line 19

def self.logger_to_stdout
  Logger.new(STDOUT)
end

.temp_dirObject



29
30
31
32
33
# File 'lib/codacy/configuration.rb', line 29

def self.temp_dir
  directory_name = Dir.tmpdir + "/codacy-coverage/"
  Dir.mkdir(directory_name) unless File.exists?(directory_name)
  directory_name
end