Skip to content
This repository was archived by the owner on Feb 19, 2020. It is now read-only.

Commit 3df6fe7

Browse files
committed
Add the option to print DEBUG logger to stdout
You can now set DEBUG_STDOUT as an environment variable to print the debug logs to the stdout
1 parent d449f27 commit 3df6fe7

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

lib/codacy/configuration.rb

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,27 @@ module Codacy
55
module Configuration
66

77
def self.logger
8-
log_filename = self.temp_dir + 'codacy-coverage_' + Date.today.to_s + '.log'
9-
log_file = File.open(log_filename, 'a')
10-
11-
logger_file = Logger.new(log_file)
12-
logger_file.level = Logger::DEBUG
8+
logger_info = logger_to_stdout
9+
logger_info.level = Logger::INFO
1310

14-
logger_stdout = Logger.new(STDOUT)
15-
logger_stdout.level = Logger::INFO
11+
logger_debug = ENV["DEBUG_STDOUT"] ? logger_to_stdout : logger_to_file
12+
logger_debug.level = Logger::DEBUG
1613

17-
log = MultiLogger.new(logger_stdout, logger_file)
14+
log = MultiLogger.new(logger_info, logger_debug)
1815

1916
log
2017
end
2118

19+
def self.logger_to_stdout
20+
Logger.new(STDOUT)
21+
end
22+
23+
def self.logger_to_file
24+
log_filename = self.temp_dir + 'codacy-coverage_' + Date.today.to_s + '.log'
25+
log_file = File.open(log_filename, 'a')
26+
Logger.new(log_file)
27+
end
28+
2229
def self.temp_dir
2330
directory_name = Dir.tmpdir + "/codacy-coverage/"
2431
Dir.mkdir(directory_name) unless File.exists?(directory_name)

0 commit comments

Comments
 (0)