Class: GitLab::CI::Lint::Log
- Includes:
- Singleton
- Defined in:
- lib/gitlab/ci/lint/log.rb
Constant Summary
Constants inherited from Colors
Colors::BACKGROUD_COLORS, Colors::COLORS
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
Instance Method Summary collapse
- #debug(message, color = :green) ⇒ Object
- #error(message, color = :green) ⇒ Object
- #info(message, color = :green) ⇒ Object
-
#initialize(log_file = "./file.log") ⇒ Log
constructor
A new instance of Log.
- #set_level(level) ⇒ Object
- #warn(message) ⇒ Object
Methods inherited from Colors
Constructor Details
#initialize(log_file = "./file.log") ⇒ Log
Returns a new instance of Log.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/gitlab/ci/lint/log.rb', line 12 def initialize log_file="./file.log" @logger = Logger.new GitLab::CI::Lint::MultiIO.new(STDOUT, File.open(File.exist?(log_file) ? log_file : "./file.log", "a")) @logger.level = Logger::INFO @logger.formatter = proc do |severity, datetime, progname, msg| datetime = "[#{datetime.strftime('%Y-%m-%d %H:%M:%S')}]" case severity when "INFO" colorized_severity = self.class.colorize("#{severity}", "black", "green") self.class.colorize("#{colorized_severity} - #{datetime} - #{msg}\n", "black", "green") when "ERROR" colorized_severity = self.class.colorize("#{severity}", "black", "red") "#{colorized_severity} - #{datetime} - #{msg}\n" end end end |
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
11 12 13 |
# File 'lib/gitlab/ci/lint/log.rb', line 11 def logger @logger end |
Instance Method Details
#debug(message, color = :green) ⇒ Object
39 40 41 |
# File 'lib/gitlab/ci/lint/log.rb', line 39 def debug , color=:green @logger.debug() end |
#error(message, color = :green) ⇒ Object
43 44 45 |
# File 'lib/gitlab/ci/lint/log.rb', line 43 def error , color=:green @logger.error() end |
#info(message, color = :green) ⇒ Object
35 36 37 |
# File 'lib/gitlab/ci/lint/log.rb', line 35 def info , color=:green @logger.info() end |
#set_level(level) ⇒ Object
31 32 33 |
# File 'lib/gitlab/ci/lint/log.rb', line 31 def set_level level @logger.level = level end |
#warn(message) ⇒ Object
47 48 49 |
# File 'lib/gitlab/ci/lint/log.rb', line 47 def warn @logger.warn() end |