Module: R10K::Logging
- Extended by:
- Forwardable
- Included in:
- Cri::CommandDSL, Action::Base, Action::Runner, Deployment::Config, Environment::Git, Environment::SVN, Feature, Forge::ModuleRelease, Git, Git::Cache, Git::Rugged::BaseRepository, Git::Rugged::Credentials, Git::ShellGit::BaseRepository, Git::StatefulRepository, Initializers::BaseInitializer, Module::Forge, Module::Local, Puppetfile, SVN::Remote, SVN::WorkingDir, Settings::Loader, Source::Git, Source::SVN, Util::Attempt, Util::Basedir, Util::License, Util::Subprocess
- Defined in:
- lib/r10k/logging.rb,
lib/r10k/logging/terminaloutputter.rb
Defined Under Namespace
Classes: TerminalOutputter
Constant Summary collapse
- LOG_LEVELS =
%w{DEBUG2 DEBUG1 DEBUG INFO NOTICE WARN ERROR FATAL}
Class Attribute Summary collapse
-
.formatter ⇒ Object
readonly
Returns the value of attribute formatter.
-
.level ⇒ Object
Returns the value of attribute level.
-
.outputter ⇒ Object
readonly
Returns the value of attribute outputter.
Class Method Summary collapse
- .debug_formatter ⇒ Object
- .default_formatter ⇒ Object
- .default_outputter ⇒ Object
-
.parse_level(input) ⇒ Integer, NilClass
private
Convert the input to a valid Log4r log level.
Instance Method Summary collapse
Class Attribute Details
.formatter ⇒ Object (readonly)
Returns the value of attribute formatter.
83 84 85 |
# File 'lib/r10k/logging.rb', line 83 def formatter @formatter end |
.level ⇒ Object
Returns the value of attribute level.
78 79 80 |
# File 'lib/r10k/logging.rb', line 78 def level @level end |
.outputter ⇒ Object (readonly)
Returns the value of attribute outputter.
88 89 90 |
# File 'lib/r10k/logging.rb', line 88 def outputter @outputter end |
Class Method Details
.debug_formatter ⇒ Object
94 95 96 |
# File 'lib/r10k/logging.rb', line 94 def debug_formatter Log4r::PatternFormatter.new(:pattern => '[%d - %l] %m') end |
.default_formatter ⇒ Object
90 91 92 |
# File 'lib/r10k/logging.rb', line 90 def default_formatter Log4r::PatternFormatter.new(:pattern => '%l\t -> %m') end |
.default_outputter ⇒ Object
98 99 100 |
# File 'lib/r10k/logging.rb', line 98 def default_outputter R10K::Logging::TerminalOutputter.new('terminal', $stderr, :level => self.level, :formatter => formatter) end |
.parse_level(input) ⇒ Integer, NilClass
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Convert the input to a valid Log4r log level
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/r10k/logging.rb', line 40 def parse_level(input) case input when TrueClass Log4r::INFO when /\A\d+\Z/ Integer(input) when String const_name = input.upcase if LOG_LEVELS.include?(const_name) begin Log4r.const_get(const_name.to_sym) rescue NameError end end end end |
Instance Method Details
#logger ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/r10k/logging.rb', line 16 def logger if @logger.nil? name = logger_name if Log4r::Logger[name] @logger = Log4r::Logger[name] else @logger = Log4r::Logger.new(name) @logger.add(R10K::Logging.outputter) end end @logger end |
#logger_name ⇒ Object
12 13 14 |
# File 'lib/r10k/logging.rb', line 12 def logger_name self.class.to_s end |