HEX
Server: Apache
System: Linux vpshost0650.publiccloud.com.br 4.4.79-grsec-1.lc.x86_64 #1 SMP Wed Aug 2 14:18:21 -03 2017 x86_64
User: bandeirantesbomb3 (10068)
PHP: 8.0.7
Disabled: apache_child_terminate,dl,escapeshellarg,escapeshellcmd,exec,link,mail,openlog,passthru,pcntl_alarm,pcntl_exec,pcntl_fork,pcntl_get_last_error,pcntl_getpriority,pcntl_setpriority,pcntl_signal,pcntl_signal_dispatch,pcntl_sigprocmask,pcntl_sigtimedwait,pcntl_sigwaitinfo,pcntl_strerror,pcntl_wait,pcntl_waitpid,pcntl_wexitstatus,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,php_check_syntax,php_strip_whitespace,popen,proc_close,proc_open,shell_exec,symlink,system
Upload Files
File: //opt/puppetlabs/puppet/lib/ruby/vendor_ruby/mcollective/logger/syslog_logger.rb
module MCollective
  module Logger
    # Implements a syslog based logger using the standard ruby syslog class
    class Syslog_logger<Base
      require 'syslog'

      include Syslog::Constants

      def start
        config = Config.instance

        facility = syslog_facility(config.logfacility)
        level = config.loglevel.to_sym

        Syslog.close if Syslog.opened?
        Syslog.open(File.basename($0), 3, facility)

        set_level(level)
      end

      def syslog_facility(facility)
        begin
          Syslog.const_get("LOG_#{facility.upcase}")
        rescue NameError => 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)
        if @known_levels.index(level) >= @known_levels.index(@active_level)
          Syslog.send(map_level(level), "#{from} #{msg}")
        end
      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