Module: Perforce2Svn::Logging

Overview

A convenient module for mixins that allow to share the logging configuration everywhere easily

Constant Summary collapse

@@log =
nil

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.configure(debug) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/perforce2svn/logging.rb', line 10

def self.configure(debug)
  if @@log.nil?
    @@log = Log4r::Logger.new 'perforce2svn'
    @@log.outputters = Log4r::Outputter.stdout
    @@log.level = if ENV['RSPEC_RUNNING']
                    Log4r::FATAL
                  elsif debug
                    Log4r::DEBUG
                  else
                    Log4r::INFO
                  end
    Log4r::Outputter.stdout.formatter = Log4r::PatternFormatter.new(:pattern => "[%l]\t%M")
  end
  @@log
end

.logObject



26
27
28
# File 'lib/perforce2svn/logging.rb', line 26

def self.log
  @@log ||= configure(true)
end

Instance Method Details

#logObject

Meant for mixing into other classes for simplified logging



31
32
33
# File 'lib/perforce2svn/logging.rb', line 31

def log
  @@log ||= Logging.log
end