X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=lib%2Fmcollective%2Flogger%2Fsyslog_logger.rb;fp=lib%2Fmcollective%2Flogger%2Fsyslog_logger.rb;h=af9e46adfd900897c6d8b6cf9332c862c4288c0b;hb=b87d2f4e68281062df1913440ca5753ae63314a9;hp=0000000000000000000000000000000000000000;hpb=ab0ea530b8ac956091f17b104ab2311336cfc250;p=packages%2Fprecise%2Fmcollective.git diff --git a/lib/mcollective/logger/syslog_logger.rb b/lib/mcollective/logger/syslog_logger.rb new file mode 100644 index 0000000..af9e46a --- /dev/null +++ b/lib/mcollective/logger/syslog_logger.rb @@ -0,0 +1,51 @@ +module MCollective + module Logger + # Implements a syslog based logger using the standard ruby syslog class + class Syslog_logger e + STDERR.puts "Invalid syslog facility #{facility} supplied, reverting to USER" + Syslog::LOG_USER + end + end + + def set_logging_level(level) + # noop + end + + def valid_levels + {:info => :info, + :warn => :warning, + :debug => :debug, + :fatal => :crit, + :error => :err} + end + + def log(level, from, msg) + Syslog.send(map_level(level), "#{from} #{msg}") + rescue + # if this fails we probably cant show the user output at all, + # STDERR it as last resort + STDERR.puts("#{level}: #{msg}") + end + end + end +end