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
- #fatal(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 40 41 42 43 44 45 |
# 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 |severity, datetime, progname, msg| if progname.nil? m = "#{msg}\n" else m = "#{progname} => #{msg}\n" end @logger.debug? ? "[#{'%-5.5s' % severity}] #{datetime} - #{m}" : m end end |
Instance Method Details
#debug(msg = nil, &block) ⇒ Object
53 54 55 |
# File 'lib/git-process/git_logger.rb', line 53 def debug(msg = nil, &block) @logger.debug(msg, &block) end |
#error(msg = nil, &block) ⇒ Object
68 69 70 |
# File 'lib/git-process/git_logger.rb', line 68 def error(msg = nil, &block) @logger.error(msg, &block) end |
#fatal(msg = nil, &block) ⇒ Object
73 74 75 |
# File 'lib/git-process/git_logger.rb', line 73 def fatal(msg = nil, &block) @logger.fatal(msg, &block) end |
#info(msg = nil, &block) ⇒ Object
58 59 60 |
# File 'lib/git-process/git_logger.rb', line 58 def info(msg = nil, &block) @logger.info(msg, &block) end |
#level ⇒ Object
48 49 50 |
# File 'lib/git-process/git_logger.rb', line 48 def level @logger.level end |
#warn(msg = nil, &block) ⇒ Object
63 64 65 |
# File 'lib/git-process/git_logger.rb', line 63 def warn(msg = nil, &block) @logger.warn(msg, &block) end |