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

Commit 1291bb0

Browse files
committed
Merge pull request #7 from codacy/debug-stdout
Add the option to print DEBUG logger to stdout
2 parents 2c2627b + 63c8d6b commit 1291bb0

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,10 @@ This will install the required dependencies. Then just run the tests:
5959
bundle exec rspec
6060
```
6161

62+
By default, the debug info will be logged into a file. If you want the debug info to be printed to stdout you can:
63+
64+
```
65+
export DEBUG_STDOUT=true
66+
```
67+
6268
You can now check your coverage results in the Codacy dashboard of your project.

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)