Class: GitProc::GitLogger
- Inherits:
-
Object
- Object
- GitProc::GitLogger
- Defined in:
- lib/git-process/git_logger.rb
Overview
Provides a Logger for Git commands
Constant Summary collapse
- DEBUG =
Logger::DEBUG
- INFO =
Logger::INFO
- WARN =
Logger::WARN
- ERROR =
Logger::ERROR
Instance Method Summary collapse
- #debug(msg = nil, &block) ⇒ Object
- #error(msg = nil, &block) ⇒ Object
- #info(msg = nil, &block) ⇒ Object
-
#initialize(log_level = nil, out = STDOUT) ⇒ GitLogger
constructor
A new instance of GitLogger.
- #level ⇒ Object
- #warn(msg = nil, &block) ⇒ Object
Constructor Details
#initialize(log_level = nil, out = STDOUT) ⇒ GitLogger
Returns a new instance of GitLogger.
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/git-process/git_logger.rb', line 28 def initialize(log_level = nil, out = STDOUT) if out.nil? @logger = ::Logger.new(RUBY_PLATFORM =~ /mswin|mingw/ ? 'NUL:' : '/dev/null') else @logger = ::Logger.new(out) end @logger.level = log_level.nil? ? GitLogger::WARN : log_level @logger.datetime_format = '%Y-%m-%d %H:%M:%S' @logger.formatter = proc do |_, _, _, msg| "#{msg}\n" end end |
Instance Method Details
#debug(msg = nil, &block) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/git-process/git_logger.rb', line 47 def debug(msg = nil, &block) if msg.nil? @logger.debug(&block) else @logger.debug(msg) end end |
#error(msg = nil, &block) ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/git-process/git_logger.rb', line 74 def error(msg = nil, &block) if msg.nil? @logger.error(&block) else @logger.error(msg) end end |
#info(msg = nil, &block) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/git-process/git_logger.rb', line 56 def info(msg = nil, &block) if msg.nil? @logger.info(&block) else @logger.info(msg) end end |
#level ⇒ Object
42 43 44 |
# File 'lib/git-process/git_logger.rb', line 42 def level @logger.level end |
#warn(msg = nil, &block) ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/git-process/git_logger.rb', line 65 def warn(msg = nil, &block) if msg.nil? @logger.send(:warn, &block) else @logger.send(:warn, msg) end end |