summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2015-04-22 12:53:30 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2015-05-06 15:09:44 -0700
commit39df692406d0a9aee28c634584c7f708d8dcd243 (patch)
treeb800fcf8979184e118b6fc0121030ab7ae816fbf
parent460a06a241237972ac602f470a558e18bdef595f (diff)
downloadchef-39df692406d0a9aee28c634584c7f708d8dcd243.tar.gz
add Chef::Log::Syslog class
See: * https://www.kickflop.net/blog/2013/06/27/syslog-output-for-chef-runs/ * http://lists.opscode.com/sympa/arc/chef/2014-12/msg00152.html * https://github.com/higanworks-cookbooks/chef-client_syslog It is relatively embarrassing to have a system administration tool that doesn't support syslog out of the box.
-rw-r--r--chef.gemspec2
-rw-r--r--lib/chef/log.rb17
2 files changed, 19 insertions, 0 deletions
diff --git a/chef.gemspec b/chef.gemspec
index ec600f1f89..7cf6380062 100644
--- a/chef.gemspec
+++ b/chef.gemspec
@@ -41,6 +41,8 @@ Gem::Specification.new do |s|
s.add_dependency "serverspec", "~> 2.7"
s.add_dependency "specinfra", "~> 2.10"
+ s.add_dependency "syslog-logger", "~> 1.6"
+
s.add_development_dependency "rack"
# Rake 10.2 drops Ruby 1.8 support
diff --git a/lib/chef/log.rb b/lib/chef/log.rb
index 682afcea4b..fc90aba595 100644
--- a/lib/chef/log.rb
+++ b/lib/chef/log.rb
@@ -21,9 +21,26 @@ require 'logger'
require 'chef/monologger'
require 'chef/exceptions'
require 'mixlib/log'
+require 'syslog-logger'
class Chef
class Log
+ #
+ # Chef::Log::Syslog class.
+ # usage in client.rb:
+ # log_location Chef::Log::Syslog.new("::Syslog::LOG_DAEMON", "chef-client")
+ #
+ class Syslog < Logger::Syslog
+ attr_accessor :sync, :formatter
+
+ def write(message)
+ self << message
+ end
+
+ def close
+ end
+ end
+
extend Mixlib::Log
# Force initialization of the primary log device (@logger)