Class: Chef::Log
- Inherits:
-
Object
- Object
- Chef::Log
- Extended by:
- Mixlib::Log
- Defined in:
- lib/chef/log.rb,
lib/chef/log/syslog.rb,
lib/chef/log/winevt.rb
Defined Under Namespace
Classes: Formatter, Syslog, WinEvt
Class Method Summary collapse
-
.caller_location ⇒ String
Get the location of the caller (from the recipe).
-
.deprecation(msg, &block) ⇒ Object
Log a deprecation warning.
- .setup! ⇒ Object
Class Method Details
.caller_location ⇒ String
Get the location of the caller (from the recipe). Grabs the first caller that is not in the chef gem proper (allowing us to weed out internal calls and give the user a more useful perspective).
52 53 54 55 56 57 |
# File 'lib/chef/log.rb', line 52 def self.caller_location # Pick the first caller that is *not* part of the Chef gem, that's the # thing the user wrote. Or failing that, the most recent caller. chef_gem_path = File.("..", __dir__) caller(0..20).find { |c| !c.start_with?(chef_gem_path) } || caller(0..1)[0] end |
.deprecation(msg, &block) ⇒ Object
Log a deprecation warning.
If the treat_deprecation_warnings_as_errors config option is set, this will raise an exception instead.
65 66 67 68 69 70 71 72 |
# File 'lib/chef/log.rb', line 65 def self.deprecation(msg, &block) if Chef::Config[:treat_deprecation_warnings_as_errors] error(msg, &block) raise Chef::Exceptions::DeprecatedFeatureError.new(msg) else warn(msg, &block) end end |
.setup! ⇒ Object
31 32 33 34 |
# File 'lib/chef/log.rb', line 31 def self.setup! init(MonoLogger.new(STDOUT)) nil end |