f647dc0d98
colorize is licensed under GPL-2 which conflicts with the MIT license of github_changelog_generator. This changes all usage of colorize to rainbow which does have a compatible license (MIT)
38 lines
926 B
Ruby
38 lines
926 B
Ruby
require "logger"
|
|
module GitHubChangelogGenerator
|
|
module Helper
|
|
# @return true if the currently running program is a unit test
|
|
def self.test?
|
|
defined? SpecHelper
|
|
end
|
|
|
|
@log ||= if test?
|
|
Logger.new(nil) # don't show any logs when running tests
|
|
else
|
|
Logger.new(STDOUT)
|
|
end
|
|
@log.formatter = proc do |severity, _datetime, _progname, msg|
|
|
string = "#{msg}\n"
|
|
|
|
if severity == "DEBUG"
|
|
string = string.color(:magenta)
|
|
elsif severity == "INFO"
|
|
string = string.color(:white)
|
|
elsif severity == "WARN"
|
|
string = string.color(:yellow)
|
|
elsif severity == "ERROR"
|
|
string = string.color(:red)
|
|
elsif severity == "FATAL"
|
|
string = string.color(:red).bright
|
|
end
|
|
|
|
string
|
|
end
|
|
|
|
# Logging happens using this method
|
|
class << self
|
|
attr_reader :log
|
|
end
|
|
end
|
|
end
|