/usr/lib/ruby/vendor_ruby/ramaze/log/syslog.rb is in ruby-ramaze 2012.12.08-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | # Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
# Copyright (c) 2008 rob@rebeltechnologies.nl
# All files in this distribution are subject to the terms of the MIT license.
require 'syslog'
module Ramaze
module Logger
##
# Logger class for writing to syslog. It is a *very* thin wrapper
# around the Syslog library.
#
class Syslog
include Logging
# Hash containing various method aliases. Rbx and Jruby don't seem to like
# the combination of alias() and module_function() so this works around
# that.
ALIASES = {:dev => :debug, :warn => :warning, :error => :err}
##
# Open the syslog library, if it is allready open, we reopen it using the
# new argument list. The argument list is passed on to the Syslog library
# so please check that, and man syslog for detailed information.
#
# There are 3 parameters:
#
# * ident: The identification used in the log file, defaults to $0
# * options: defaults to Syslog::LOG_PID | Syslog::LOG_CONS
# * facility: defaults to Syslog::LOG_USER
#
def initialize(*args)
::Syslog.close if ::Syslog.opened?
::Syslog.open(*args)
end
##
# Just sends all messages received to ::Syslog
# We simply return if the log was closed for some reason, this behavior
# was copied from Informer. We do not handle levels here. This will
# be done by the syslog daemon based on it's configuration.
def log(tag, *messages)
return if !::Syslog.opened?
tag = tag.to_sym
if ALIASES.key?(tag)
tag = ALIASES[tag]
end
messages = messages.map {|m| m.gsub(/(%[^m])/,'%\1')}
::Syslog.send(tag, *messages)
end
##
# Has to call the modules singleton-method.
#
def inspect
::Syslog.inspect
end
end # Syslog
end # Logger
end # Ramaze
|