diff options
| author | Daniel Pittman <daniel@puppetlabs.com> | 2011-02-03 14:25:46 -0800 |
|---|---|---|
| committer | Daniel Pittman <daniel@rimspace.net> | 2011-02-03 14:25:46 -0800 |
| commit | 0502c557cbe8dc0d039e05ff5940a9e3b7e5c150 (patch) | |
| tree | 2603d5e7eeeca1daea2ffcc678b0049e877c53f5 /lib | |
| parent | 876d0503dd93329a73e7f335c10a47330d745293 (diff) | |
| parent | c912a2af2f63f505a493137d4ff0b88bc3754cda (diff) | |
| download | puppet-0502c557cbe8dc0d039e05ff5940a9e3b7e5c150.tar.gz puppet-0502c557cbe8dc0d039e05ff5940a9e3b7e5c150.tar.xz puppet-0502c557cbe8dc0d039e05ff5940a9e3b7e5c150.zip | |
Merge branch 'bug/2.6.next/4139-autoflush-doesn't' into 2.6.next
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/puppet/defaults.rb | 6 | ||||
| -rw-r--r-- | lib/puppet/util/log.rb | 6 | ||||
| -rw-r--r-- | lib/puppet/util/log/destinations.rb | 2 |
3 files changed, 13 insertions, 1 deletions
diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb index 764cbbe2b..687ac4eb0 100644 --- a/lib/puppet/defaults.rb +++ b/lib/puppet/defaults.rb @@ -14,7 +14,11 @@ module Puppet setdefaults(:main, :trace => [false, "Whether to print stack traces on some errors"], - :autoflush => [false, "Whether log files should always flush to disk."], + :autoflush => { + :default => false, + :desc => "Whether log files should always flush to disk.", + :hook => proc { |value| Log.autoflush = value } + }, :syslogfacility => ["daemon", "What syslog facility to use when logging to syslog. Syslog has a fixed list of valid facilities, and you must choose one of those; you cannot just make one up."], diff --git a/lib/puppet/util/log.rb b/lib/puppet/util/log.rb index 3fdac3f69..ba1690078 100644 --- a/lib/puppet/util/log.rb +++ b/lib/puppet/util/log.rb @@ -67,6 +67,12 @@ class Puppet::Util::Log } end + def Log.autoflush=(v) + @destinations.each do |type, dest| + dest.autoflush = v if dest.respond_to?(:autoflush=) + end + end + # Create a new log message. The primary role of this method is to # avoid creating log messages below the loglevel. def Log.create(hash) diff --git a/lib/puppet/util/log/destinations.rb b/lib/puppet/util/log/destinations.rb index 22b3dedb2..c70edeb02 100644 --- a/lib/puppet/util/log/destinations.rb +++ b/lib/puppet/util/log/destinations.rb @@ -50,6 +50,8 @@ Puppet::Util::Log.newdesttype :file do @file.flush if defined?(@file) end + attr_accessor :autoflush + def initialize(path) @name = path # first make sure the directory exists |
