Module: Codacy::Configuration
- Defined in:
- lib/codacy/configuration.rb
Defined Under Namespace
Classes: MultiLogger
Class Method Summary collapse
- .log_file_name ⇒ Object
- .logger ⇒ Object
- .logger_to_file ⇒ Object
- .logger_to_stdout ⇒ Object
- .temp_dir ⇒ Object
Class Method Details
.log_file_name ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/codacy/configuration.rb', line 29 def self.log_file_name today = Date.today # rails overrides to_s method of Date class # https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/date/conversions.rb#L52 = today.respond_to?(:to_default_s) ? today.to_default_s : today.to_s 'codacy-coverage_' + + '.log' end |
.logger ⇒ Object
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_file ⇒ Object
23 24 25 26 27 |
# File 'lib/codacy/configuration.rb', line 23 def self.logger_to_file log_file_path = self.temp_dir + self.log_file_name log_file = File.open(log_file_path, 'a') Logger.new(log_file) end |
.logger_to_stdout ⇒ Object
19 20 21 |
# File 'lib/codacy/configuration.rb', line 19 def self.logger_to_stdout Logger.new(STDOUT) end |
.temp_dir ⇒ Object
37 38 39 40 41 |
# File 'lib/codacy/configuration.rb', line 37 def self.temp_dir directory_name = Dir.tmpdir + "/codacy-coverage/" Dir.mkdir(directory_name) unless File.exists?(directory_name) directory_name end |