scashin133-syslog_logger 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
 - data/.gitignore +21 -0
 - data/LICENSE +20 -0
 - data/README.rdoc +17 -0
 - data/Rakefile +54 -0
 - data/VERSION +1 -0
 - data/lib/syslog_logger.rb +114 -0
 - data/lib/syslog_logger_env_formatting.rb +38 -0
 - data/scashin133-syslog_logger.gemspec +58 -0
 - data/test/helper.rb +11 -0
 - data/test/test_syslog_logger.rb +25 -0
 - metadata +113 -0
 
    
        data/.document
    ADDED
    
    
    
        data/.gitignore
    ADDED
    
    
    
        data/LICENSE
    ADDED
    
    | 
         @@ -0,0 +1,20 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Copyright (c) 2009 Sean Cashin
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining
         
     | 
| 
      
 4 
     | 
    
         
            +
            a copy of this software and associated documentation files (the
         
     | 
| 
      
 5 
     | 
    
         
            +
            "Software"), to deal in the Software without restriction, including
         
     | 
| 
      
 6 
     | 
    
         
            +
            without limitation the rights to use, copy, modify, merge, publish,
         
     | 
| 
      
 7 
     | 
    
         
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         
     | 
| 
      
 8 
     | 
    
         
            +
            permit persons to whom the Software is furnished to do so, subject to
         
     | 
| 
      
 9 
     | 
    
         
            +
            the following conditions:
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be
         
     | 
| 
      
 12 
     | 
    
         
            +
            included in all copies or substantial portions of the Software.
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         
     | 
| 
      
 15 
     | 
    
         
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         
     | 
| 
      
 16 
     | 
    
         
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         
     | 
| 
      
 17 
     | 
    
         
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         
     | 
| 
      
 18 
     | 
    
         
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         
     | 
| 
      
 19 
     | 
    
         
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         
     | 
| 
      
 20 
     | 
    
         
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         
     | 
    
        data/README.rdoc
    ADDED
    
    | 
         @@ -0,0 +1,17 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            = syslog_logger
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Description goes here.
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            == Note on Patches/Pull Requests
         
     | 
| 
      
 6 
     | 
    
         
            +
             
         
     | 
| 
      
 7 
     | 
    
         
            +
            * Fork the project.
         
     | 
| 
      
 8 
     | 
    
         
            +
            * Make your feature addition or bug fix.
         
     | 
| 
      
 9 
     | 
    
         
            +
            * Add tests for it. This is important so I don't break it in a
         
     | 
| 
      
 10 
     | 
    
         
            +
              future version unintentionally.
         
     | 
| 
      
 11 
     | 
    
         
            +
            * Commit, do not mess with rakefile, version, or history.
         
     | 
| 
      
 12 
     | 
    
         
            +
              (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
         
     | 
| 
      
 13 
     | 
    
         
            +
            * Send me a pull request. Bonus points for topic branches.
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            == Copyright
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            Copyright (c) 2010 Sean Cashin. See LICENSE for details.
         
     | 
    
        data/Rakefile
    ADDED
    
    | 
         @@ -0,0 +1,54 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rubygems'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'rake'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            begin
         
     | 
| 
      
 5 
     | 
    
         
            +
              require 'jeweler'
         
     | 
| 
      
 6 
     | 
    
         
            +
              Jeweler::Tasks.new do |gem|
         
     | 
| 
      
 7 
     | 
    
         
            +
                gem.name = "scashin133-syslog_logger"
         
     | 
| 
      
 8 
     | 
    
         
            +
                gem.summary = %Q{An improved Logger replacement that logs to syslog. It is almost drop-in with a few caveats.}
         
     | 
| 
      
 9 
     | 
    
         
            +
                gem.description = %Q{An improved Logger replacement that logs to syslog. It is almost drop-in with a few caveats.}
         
     | 
| 
      
 10 
     | 
    
         
            +
                gem.email = "drbrain@segment7.net; cpowell@prylis.com; mboeh@desperance.net; scashin133@gmail.com"
         
     | 
| 
      
 11 
     | 
    
         
            +
                gem.homepage = "http://github.com/scashin133/syslog_logger"
         
     | 
| 
      
 12 
     | 
    
         
            +
                gem.authors = ["Eric Hodel"," Chris Powell"," Matthew Boeh"," Ian Lesperance"," Dana Danger"," Brian Smith", " Ashley Martens", "Sean Cashin"]
         
     | 
| 
      
 13 
     | 
    
         
            +
                gem.add_development_dependency "shoulda", ">= 0"
         
     | 
| 
      
 14 
     | 
    
         
            +
                gem.add_development_dependency "mocha", ">= 0"
         
     | 
| 
      
 15 
     | 
    
         
            +
                # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
              Jeweler::GemcutterTasks.new
         
     | 
| 
      
 18 
     | 
    
         
            +
            rescue LoadError
         
     | 
| 
      
 19 
     | 
    
         
            +
              puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
         
     | 
| 
      
 20 
     | 
    
         
            +
            end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            require 'rake/testtask'
         
     | 
| 
      
 23 
     | 
    
         
            +
            Rake::TestTask.new(:test) do |test|
         
     | 
| 
      
 24 
     | 
    
         
            +
              test.libs << 'lib' << 'test'
         
     | 
| 
      
 25 
     | 
    
         
            +
              test.pattern = 'test/**/test_*.rb'
         
     | 
| 
      
 26 
     | 
    
         
            +
              test.verbose = true
         
     | 
| 
      
 27 
     | 
    
         
            +
            end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            begin
         
     | 
| 
      
 30 
     | 
    
         
            +
              require 'rcov/rcovtask'
         
     | 
| 
      
 31 
     | 
    
         
            +
              Rcov::RcovTask.new do |test|
         
     | 
| 
      
 32 
     | 
    
         
            +
                test.libs << 'test'
         
     | 
| 
      
 33 
     | 
    
         
            +
                test.pattern = 'test/**/test_*.rb'
         
     | 
| 
      
 34 
     | 
    
         
            +
                test.verbose = true
         
     | 
| 
      
 35 
     | 
    
         
            +
              end
         
     | 
| 
      
 36 
     | 
    
         
            +
            rescue LoadError
         
     | 
| 
      
 37 
     | 
    
         
            +
              task :rcov do
         
     | 
| 
      
 38 
     | 
    
         
            +
                abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
         
     | 
| 
      
 39 
     | 
    
         
            +
              end
         
     | 
| 
      
 40 
     | 
    
         
            +
            end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
            task :test => :check_dependencies
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
            task :default => :test
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
            require 'rake/rdoctask'
         
     | 
| 
      
 47 
     | 
    
         
            +
            Rake::RDocTask.new do |rdoc|
         
     | 
| 
      
 48 
     | 
    
         
            +
              version = File.exist?('VERSION') ? File.read('VERSION') : ""
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
              rdoc.rdoc_dir = 'rdoc'
         
     | 
| 
      
 51 
     | 
    
         
            +
              rdoc.title = "syslog_logger #{version}"
         
     | 
| 
      
 52 
     | 
    
         
            +
              rdoc.rdoc_files.include('README*')
         
     | 
| 
      
 53 
     | 
    
         
            +
              rdoc.rdoc_files.include('lib/**/*.rb')
         
     | 
| 
      
 54 
     | 
    
         
            +
            end
         
     | 
    
        data/VERSION
    ADDED
    
    | 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            1.7.1
         
     | 
| 
         @@ -0,0 +1,114 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'syslog'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'logger'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            class SyslogLogger
         
     | 
| 
      
 5 
     | 
    
         
            +
              include Logger::Severity
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              # From 'man syslog.h':
         
     | 
| 
      
 8 
     | 
    
         
            +
              # LOG_EMERG   A panic condition was reported to all processes.
         
     | 
| 
      
 9 
     | 
    
         
            +
              # LOG_ALERT   A condition that should be corrected immediately.
         
     | 
| 
      
 10 
     | 
    
         
            +
              # LOG_CRIT    A critical condition.
         
     | 
| 
      
 11 
     | 
    
         
            +
              # LOG_ERR     An error message.
         
     | 
| 
      
 12 
     | 
    
         
            +
              # LOG_WARNING A warning message.
         
     | 
| 
      
 13 
     | 
    
         
            +
              # LOG_NOTICE  A condition requiring special handling.
         
     | 
| 
      
 14 
     | 
    
         
            +
              # LOG_INFO    A general information message.
         
     | 
| 
      
 15 
     | 
    
         
            +
              # LOG_DEBUG   A message useful for debugging programs.
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              # From logger rdoc:
         
     | 
| 
      
 18 
     | 
    
         
            +
              # FATAL:  an unhandleable error that results in a program crash
         
     | 
| 
      
 19 
     | 
    
         
            +
              # ERROR:  a handleable error condition
         
     | 
| 
      
 20 
     | 
    
         
            +
              # WARN:   a warning
         
     | 
| 
      
 21 
     | 
    
         
            +
              # INFO:   generic (useful) information about system operation
         
     | 
| 
      
 22 
     | 
    
         
            +
              # DEBUG:  low-level information for developers
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              # Maps Logger warning types to syslog(3) warning types.
         
     | 
| 
      
 25 
     | 
    
         
            +
              LOGGER_MAP = {
         
     | 
| 
      
 26 
     | 
    
         
            +
                :unknown => :alert,
         
     | 
| 
      
 27 
     | 
    
         
            +
                :fatal   => :alert,
         
     | 
| 
      
 28 
     | 
    
         
            +
                :error   => :err,
         
     | 
| 
      
 29 
     | 
    
         
            +
                :warn    => :warning,
         
     | 
| 
      
 30 
     | 
    
         
            +
                :info    => :info,
         
     | 
| 
      
 31 
     | 
    
         
            +
                :debug   => :debug
         
     | 
| 
      
 32 
     | 
    
         
            +
              }
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
              # Maps Logger log levels to their values so we can silence.
         
     | 
| 
      
 35 
     | 
    
         
            +
              LOGGER_LEVEL_MAP = {}
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
              LOGGER_MAP.each_key do |key|
         
     | 
| 
      
 38 
     | 
    
         
            +
                LOGGER_LEVEL_MAP[key] = Logger.const_get key.to_s.upcase
         
     | 
| 
      
 39 
     | 
    
         
            +
              end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
              # Maps Logger log level values to syslog log levels.
         
     | 
| 
      
 42 
     | 
    
         
            +
              LEVEL_LOGGER_MAP = {}
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
              LOGGER_LEVEL_MAP.invert.each do |level, severity|
         
     | 
| 
      
 45 
     | 
    
         
            +
                LEVEL_LOGGER_MAP[level] = LOGGER_MAP[severity]
         
     | 
| 
      
 46 
     | 
    
         
            +
              end
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
              # Builds a methods for level +meth+.
         
     | 
| 
      
 49 
     | 
    
         
            +
              for severity in Logger::Severity.constants
         
     | 
| 
      
 50 
     | 
    
         
            +
                class_eval <<-EOT, __FILE__, __LINE__
         
     | 
| 
      
 51 
     | 
    
         
            +
                  def #{severity.downcase}(message = nil, progname = nil, &block)  # def debug(message = nil, progname = nil, &block)
         
     | 
| 
      
 52 
     | 
    
         
            +
                    add(#{severity}, message, progname, &block)                    #   add(DEBUG, message, progname, &block)
         
     | 
| 
      
 53 
     | 
    
         
            +
                  end                                                              # end
         
     | 
| 
      
 54 
     | 
    
         
            +
                                                                                   #
         
     | 
| 
      
 55 
     | 
    
         
            +
                  def #{severity.downcase}?                                        # def debug?
         
     | 
| 
      
 56 
     | 
    
         
            +
                    #{severity} >= @level                                          #   DEBUG >= @level
         
     | 
| 
      
 57 
     | 
    
         
            +
                  end                                                              # end
         
     | 
| 
      
 58 
     | 
    
         
            +
                EOT
         
     | 
| 
      
 59 
     | 
    
         
            +
              end
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
              # Log level for Logger compatibility.
         
     | 
| 
      
 62 
     | 
    
         
            +
              attr_accessor :level
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
              # Fills in variables for Logger compatibility.  If this is the first
         
     | 
| 
      
 65 
     | 
    
         
            +
              # instance of SyslogLogger, +program_name+ may be set to change the logged
         
     | 
| 
      
 66 
     | 
    
         
            +
              # program name and +facility+ may be set to specify a custom facility
         
     | 
| 
      
 67 
     | 
    
         
            +
              # with your syslog daemon.
         
     | 
| 
      
 68 
     | 
    
         
            +
              #
         
     | 
| 
      
 69 
     | 
    
         
            +
              # Due to the way syslog works, only one program name may be chosen.
         
     | 
| 
      
 70 
     | 
    
         
            +
              def initialize(program_name = 'rails', facility = Syslog::LOG_USER)
         
     | 
| 
      
 71 
     | 
    
         
            +
                @level = Logger::DEBUG
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
                return if defined? SYSLOG
         
     | 
| 
      
 74 
     | 
    
         
            +
                self.class.const_set :SYSLOG, Syslog.open(program_name, nil, facility)
         
     | 
| 
      
 75 
     | 
    
         
            +
              end
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
              # Almost duplicates Logger#add.  +progname+ is prepended to the beginning of a message.
         
     | 
| 
      
 78 
     | 
    
         
            +
              def add(severity, message = nil, progname = nil, &block)
         
     | 
| 
      
 79 
     | 
    
         
            +
                severity ||= Logger::UNKNOWN
         
     | 
| 
      
 80 
     | 
    
         
            +
                if severity >= @level
         
     | 
| 
      
 81 
     | 
    
         
            +
                  prepend = progname ? "[#{progname}] " : ''
         
     | 
| 
      
 82 
     | 
    
         
            +
                  message = clean((prepend + (message || block.call)))
         
     | 
| 
      
 83 
     | 
    
         
            +
                  SYSLOG.send LEVEL_LOGGER_MAP[severity], clean(message)
         
     | 
| 
      
 84 
     | 
    
         
            +
                end
         
     | 
| 
      
 85 
     | 
    
         
            +
                true
         
     | 
| 
      
 86 
     | 
    
         
            +
              end
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
              # Allows messages of a particular log level to be ignored temporarily.
         
     | 
| 
      
 89 
     | 
    
         
            +
              def silence(temporary_level = Logger::ERROR)
         
     | 
| 
      
 90 
     | 
    
         
            +
                old_logger_level = @level
         
     | 
| 
      
 91 
     | 
    
         
            +
                @level = temporary_level
         
     | 
| 
      
 92 
     | 
    
         
            +
                yield
         
     | 
| 
      
 93 
     | 
    
         
            +
              ensure
         
     | 
| 
      
 94 
     | 
    
         
            +
                @level = old_logger_level
         
     | 
| 
      
 95 
     | 
    
         
            +
              end
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
              # In Logger, this dumps the raw message; the closest equivalent
         
     | 
| 
      
 98 
     | 
    
         
            +
              # would be Logger::UNKNOWN
         
     | 
| 
      
 99 
     | 
    
         
            +
              def <<(message)
         
     | 
| 
      
 100 
     | 
    
         
            +
                add(Logger::UNKNOWN, message)
         
     | 
| 
      
 101 
     | 
    
         
            +
              end
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
            private
         
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
      
 105 
     | 
    
         
            +
              # Clean up messages so they're nice and pretty.
         
     | 
| 
      
 106 
     | 
    
         
            +
              def clean(message)
         
     | 
| 
      
 107 
     | 
    
         
            +
                message = message.to_s.dup
         
     | 
| 
      
 108 
     | 
    
         
            +
                message.strip!
         
     | 
| 
      
 109 
     | 
    
         
            +
                message.gsub!(/%/, '%%') # syslog(3) freaks on % (printf)
         
     | 
| 
      
 110 
     | 
    
         
            +
                message.gsub!(/\e\[[^m]*m/, '') # remove useless ansi color codes
         
     | 
| 
      
 111 
     | 
    
         
            +
                return message
         
     | 
| 
      
 112 
     | 
    
         
            +
              end
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,38 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Adds some default information to syslog messages.
         
     | 
| 
      
 2 
     | 
    
         
            +
            # If you pass a User or Device object as the first parameter, it will log that user/device's id
         
     | 
| 
      
 3 
     | 
    
         
            +
            # If you pass a block from a controller, it will automatically log the current user id
         
     | 
| 
      
 4 
     | 
    
         
            +
            # If you pass a block, the class name of the block's context will be added
         
     | 
| 
      
 5 
     | 
    
         
            +
            # 
         
     | 
| 
      
 6 
     | 
    
         
            +
            # Examples
         
     | 
| 
      
 7 
     | 
    
         
            +
            # logger.debug "O'Doyle Rules!" 
         
     | 
| 
      
 8 
     | 
    
         
            +
            #     #=> [development] [DEBUG: 2008-01-25 14:16:12.12345] O'Doyle Rules!
         
     | 
| 
      
 9 
     | 
    
         
            +
            # 
         
     | 
| 
      
 10 
     | 
    
         
            +
            # #from within a controller...
         
     | 
| 
      
 11 
     | 
    
         
            +
            # logger.error {"Something is messed up!"}
         
     | 
| 
      
 12 
     | 
    
         
            +
            #     #=> [development] [ERROR: 2008-01-25 14:16:12.12345] [123] [ClassName] Something is messed up!
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            class SyslogLogger
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                # short names for "DEBUG", "INFO", ...
         
     | 
| 
      
 17 
     | 
    
         
            +
                # must be ordered to correspond to severity constants defined in 
         
     | 
| 
      
 18 
     | 
    
         
            +
                # ActiveSupport::BufferedLogger::Severity 
         
     | 
| 
      
 19 
     | 
    
         
            +
                #@@log_level_names = %w( D I W E F U )
         
     | 
| 
      
 20 
     | 
    
         
            +
                #LOG_NAME_FIELD_WIDTH = 1
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                @@log_level_names = %w( DEBUG INFO WARN ERROR FATAL UNKNOWN )
         
     | 
| 
      
 23 
     | 
    
         
            +
                LOG_NAME_FIELD_WIDTH = 7
         
     | 
| 
      
 24 
     | 
    
         
            +
                
         
     | 
| 
      
 25 
     | 
    
         
            +
                def add_with_formatting(severity, message = nil, progname = nil, &block)
         
     | 
| 
      
 26 
     | 
    
         
            +
                  severity ||= Logger::UNKNOWN
         
     | 
| 
      
 27 
     | 
    
         
            +
                  message = "[#{RAILS_ENV}] [#{@@log_level_names[severity].ljust(LOG_NAME_FIELD_WIDTH)}: #{time.strftime("%Y-%m-%d %H:%M:%S")}.#{time.usec.to_s.rjust(6, '0')}] #{message}"
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                  if(block)
         
     | 
| 
      
 30 
     | 
    
         
            +
                    add_without_formatting(severity, message, progname,
         
     | 
| 
      
 31 
     | 
    
         
            +
                      &Proc.new{g_log_formatter(severity, nil, user, &block)})
         
     | 
| 
      
 32 
     | 
    
         
            +
                  else
         
     | 
| 
      
 33 
     | 
    
         
            +
                    add_without_formatting(severity, message, progname)
         
     | 
| 
      
 34 
     | 
    
         
            +
                  end
         
     | 
| 
      
 35 
     | 
    
         
            +
                end
         
     | 
| 
      
 36 
     | 
    
         
            +
                alias_method_chain :add, :formatting
         
     | 
| 
      
 37 
     | 
    
         
            +
                
         
     | 
| 
      
 38 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,58 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Generated by jeweler
         
     | 
| 
      
 2 
     | 
    
         
            +
            # DO NOT EDIT THIS FILE DIRECTLY
         
     | 
| 
      
 3 
     | 
    
         
            +
            # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
         
     | 
| 
      
 4 
     | 
    
         
            +
            # -*- encoding: utf-8 -*-
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            Gem::Specification.new do |s|
         
     | 
| 
      
 7 
     | 
    
         
            +
              s.name = %q{scashin133-syslog_logger}
         
     | 
| 
      
 8 
     | 
    
         
            +
              s.version = "1.7.1"
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         
     | 
| 
      
 11 
     | 
    
         
            +
              s.authors = ["Eric Hodel", " Chris Powell", " Matthew Boeh", " Ian Lesperance", " Dana Danger", " Brian Smith", " Ashley Martens", "Sean Cashin"]
         
     | 
| 
      
 12 
     | 
    
         
            +
              s.date = %q{2010-08-18}
         
     | 
| 
      
 13 
     | 
    
         
            +
              s.description = %q{An improved Logger replacement that logs to syslog. It is almost drop-in with a few caveats.}
         
     | 
| 
      
 14 
     | 
    
         
            +
              s.email = %q{drbrain@segment7.net; cpowell@prylis.com; mboeh@desperance.net; scashin133@gmail.com}
         
     | 
| 
      
 15 
     | 
    
         
            +
              s.extra_rdoc_files = [
         
     | 
| 
      
 16 
     | 
    
         
            +
                "LICENSE",
         
     | 
| 
      
 17 
     | 
    
         
            +
                 "README.rdoc"
         
     | 
| 
      
 18 
     | 
    
         
            +
              ]
         
     | 
| 
      
 19 
     | 
    
         
            +
              s.files = [
         
     | 
| 
      
 20 
     | 
    
         
            +
                ".document",
         
     | 
| 
      
 21 
     | 
    
         
            +
                 ".gitignore",
         
     | 
| 
      
 22 
     | 
    
         
            +
                 "LICENSE",
         
     | 
| 
      
 23 
     | 
    
         
            +
                 "README.rdoc",
         
     | 
| 
      
 24 
     | 
    
         
            +
                 "Rakefile",
         
     | 
| 
      
 25 
     | 
    
         
            +
                 "VERSION",
         
     | 
| 
      
 26 
     | 
    
         
            +
                 "lib/syslog_logger.rb",
         
     | 
| 
      
 27 
     | 
    
         
            +
                 "lib/syslog_logger_env_formatting.rb",
         
     | 
| 
      
 28 
     | 
    
         
            +
                 "scashin133-syslog_logger.gemspec",
         
     | 
| 
      
 29 
     | 
    
         
            +
                 "test/helper.rb",
         
     | 
| 
      
 30 
     | 
    
         
            +
                 "test/test_syslog_logger.rb"
         
     | 
| 
      
 31 
     | 
    
         
            +
              ]
         
     | 
| 
      
 32 
     | 
    
         
            +
              s.homepage = %q{http://github.com/scashin133/syslog_logger}
         
     | 
| 
      
 33 
     | 
    
         
            +
              s.rdoc_options = ["--charset=UTF-8"]
         
     | 
| 
      
 34 
     | 
    
         
            +
              s.require_paths = ["lib"]
         
     | 
| 
      
 35 
     | 
    
         
            +
              s.rubygems_version = %q{1.3.7}
         
     | 
| 
      
 36 
     | 
    
         
            +
              s.summary = %q{An improved Logger replacement that logs to syslog. It is almost drop-in with a few caveats.}
         
     | 
| 
      
 37 
     | 
    
         
            +
              s.test_files = [
         
     | 
| 
      
 38 
     | 
    
         
            +
                "test/helper.rb",
         
     | 
| 
      
 39 
     | 
    
         
            +
                 "test/test_syslog_logger.rb"
         
     | 
| 
      
 40 
     | 
    
         
            +
              ]
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
              if s.respond_to? :specification_version then
         
     | 
| 
      
 43 
     | 
    
         
            +
                current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
         
     | 
| 
      
 44 
     | 
    
         
            +
                s.specification_version = 3
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
         
     | 
| 
      
 47 
     | 
    
         
            +
                  s.add_development_dependency(%q<shoulda>, [">= 0"])
         
     | 
| 
      
 48 
     | 
    
         
            +
                  s.add_development_dependency(%q<mocha>, [">= 0"])
         
     | 
| 
      
 49 
     | 
    
         
            +
                else
         
     | 
| 
      
 50 
     | 
    
         
            +
                  s.add_dependency(%q<shoulda>, [">= 0"])
         
     | 
| 
      
 51 
     | 
    
         
            +
                  s.add_dependency(%q<mocha>, [">= 0"])
         
     | 
| 
      
 52 
     | 
    
         
            +
                end
         
     | 
| 
      
 53 
     | 
    
         
            +
              else
         
     | 
| 
      
 54 
     | 
    
         
            +
                s.add_dependency(%q<shoulda>, [">= 0"])
         
     | 
| 
      
 55 
     | 
    
         
            +
                s.add_dependency(%q<mocha>, [">= 0"])
         
     | 
| 
      
 56 
     | 
    
         
            +
              end
         
     | 
| 
      
 57 
     | 
    
         
            +
            end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
    
        data/test/helper.rb
    ADDED
    
    | 
         @@ -0,0 +1,11 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rubygems'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'test/unit'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'shoulda'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'mocha'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
         
     | 
| 
      
 7 
     | 
    
         
            +
            $LOAD_PATH.unshift(File.dirname(__FILE__))
         
     | 
| 
      
 8 
     | 
    
         
            +
            require 'syslog_logger'
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            class Test::Unit::TestCase
         
     | 
| 
      
 11 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class TestSyslogLogger < Test::Unit::TestCase
         
     | 
| 
      
 4 
     | 
    
         
            +
              context "on first initialization of default SyslogLogger object" do
         
     | 
| 
      
 5 
     | 
    
         
            +
                setup do
         
     | 
| 
      
 6 
     | 
    
         
            +
                  @logger = SyslogLogger.new
         
     | 
| 
      
 7 
     | 
    
         
            +
                end
         
     | 
| 
      
 8 
     | 
    
         
            +
                should "have level set to DEBUG" do
         
     | 
| 
      
 9 
     | 
    
         
            +
                  assert_equal @logger.level, Logger::DEBUG
         
     | 
| 
      
 10 
     | 
    
         
            +
                end
         
     | 
| 
      
 11 
     | 
    
         
            +
              end
         
     | 
| 
      
 12 
     | 
    
         
            +
              context "a SyslogLogger object" do
         
     | 
| 
      
 13 
     | 
    
         
            +
                setup do
         
     | 
| 
      
 14 
     | 
    
         
            +
                  @logger = SyslogLogger.new
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
                Logger::Severity.constants.each do |severity|
         
     | 
| 
      
 17 
     | 
    
         
            +
                  should "respond to method #{severity}" do
         
     | 
| 
      
 18 
     | 
    
         
            +
                    @logger.send(severity.downcase.to_sym, 'message', 'progname')
         
     | 
| 
      
 19 
     | 
    
         
            +
                  end
         
     | 
| 
      
 20 
     | 
    
         
            +
                  should "respond to method #{severity}?" do
         
     | 
| 
      
 21 
     | 
    
         
            +
                    @logger.send("#{severity.downcase}?".to_sym)
         
     | 
| 
      
 22 
     | 
    
         
            +
                  end
         
     | 
| 
      
 23 
     | 
    
         
            +
                end
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,113 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification 
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: scashin133-syslog_logger
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version 
         
     | 
| 
      
 4 
     | 
    
         
            +
              hash: 9
         
     | 
| 
      
 5 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 6 
     | 
    
         
            +
              segments: 
         
     | 
| 
      
 7 
     | 
    
         
            +
              - 1
         
     | 
| 
      
 8 
     | 
    
         
            +
              - 7
         
     | 
| 
      
 9 
     | 
    
         
            +
              - 1
         
     | 
| 
      
 10 
     | 
    
         
            +
              version: 1.7.1
         
     | 
| 
      
 11 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 12 
     | 
    
         
            +
            authors: 
         
     | 
| 
      
 13 
     | 
    
         
            +
            - Eric Hodel
         
     | 
| 
      
 14 
     | 
    
         
            +
            - " Chris Powell"
         
     | 
| 
      
 15 
     | 
    
         
            +
            - " Matthew Boeh"
         
     | 
| 
      
 16 
     | 
    
         
            +
            - " Ian Lesperance"
         
     | 
| 
      
 17 
     | 
    
         
            +
            - " Dana Danger"
         
     | 
| 
      
 18 
     | 
    
         
            +
            - " Brian Smith"
         
     | 
| 
      
 19 
     | 
    
         
            +
            - " Ashley Martens"
         
     | 
| 
      
 20 
     | 
    
         
            +
            - Sean Cashin
         
     | 
| 
      
 21 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 22 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 23 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            date: 2010-08-18 00:00:00 -07:00
         
     | 
| 
      
 26 
     | 
    
         
            +
            default_executable: 
         
     | 
| 
      
 27 
     | 
    
         
            +
            dependencies: 
         
     | 
| 
      
 28 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 29 
     | 
    
         
            +
              name: shoulda
         
     | 
| 
      
 30 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 31 
     | 
    
         
            +
              requirement: &id001 !ruby/object:Gem::Requirement 
         
     | 
| 
      
 32 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 33 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 34 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 35 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 36 
     | 
    
         
            +
                    hash: 3
         
     | 
| 
      
 37 
     | 
    
         
            +
                    segments: 
         
     | 
| 
      
 38 
     | 
    
         
            +
                    - 0
         
     | 
| 
      
 39 
     | 
    
         
            +
                    version: "0"
         
     | 
| 
      
 40 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 41 
     | 
    
         
            +
              version_requirements: *id001
         
     | 
| 
      
 42 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 43 
     | 
    
         
            +
              name: mocha
         
     | 
| 
      
 44 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 45 
     | 
    
         
            +
              requirement: &id002 !ruby/object:Gem::Requirement 
         
     | 
| 
      
 46 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 47 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 48 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 49 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 50 
     | 
    
         
            +
                    hash: 3
         
     | 
| 
      
 51 
     | 
    
         
            +
                    segments: 
         
     | 
| 
      
 52 
     | 
    
         
            +
                    - 0
         
     | 
| 
      
 53 
     | 
    
         
            +
                    version: "0"
         
     | 
| 
      
 54 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 55 
     | 
    
         
            +
              version_requirements: *id002
         
     | 
| 
      
 56 
     | 
    
         
            +
            description: An improved Logger replacement that logs to syslog. It is almost drop-in with a few caveats.
         
     | 
| 
      
 57 
     | 
    
         
            +
            email: drbrain@segment7.net; cpowell@prylis.com; mboeh@desperance.net; scashin133@gmail.com
         
     | 
| 
      
 58 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
            extra_rdoc_files: 
         
     | 
| 
      
 63 
     | 
    
         
            +
            - LICENSE
         
     | 
| 
      
 64 
     | 
    
         
            +
            - README.rdoc
         
     | 
| 
      
 65 
     | 
    
         
            +
            files: 
         
     | 
| 
      
 66 
     | 
    
         
            +
            - .document
         
     | 
| 
      
 67 
     | 
    
         
            +
            - .gitignore
         
     | 
| 
      
 68 
     | 
    
         
            +
            - LICENSE
         
     | 
| 
      
 69 
     | 
    
         
            +
            - README.rdoc
         
     | 
| 
      
 70 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 71 
     | 
    
         
            +
            - VERSION
         
     | 
| 
      
 72 
     | 
    
         
            +
            - lib/syslog_logger.rb
         
     | 
| 
      
 73 
     | 
    
         
            +
            - lib/syslog_logger_env_formatting.rb
         
     | 
| 
      
 74 
     | 
    
         
            +
            - scashin133-syslog_logger.gemspec
         
     | 
| 
      
 75 
     | 
    
         
            +
            - test/helper.rb
         
     | 
| 
      
 76 
     | 
    
         
            +
            - test/test_syslog_logger.rb
         
     | 
| 
      
 77 
     | 
    
         
            +
            has_rdoc: true
         
     | 
| 
      
 78 
     | 
    
         
            +
            homepage: http://github.com/scashin133/syslog_logger
         
     | 
| 
      
 79 
     | 
    
         
            +
            licenses: []
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 82 
     | 
    
         
            +
            rdoc_options: 
         
     | 
| 
      
 83 
     | 
    
         
            +
            - --charset=UTF-8
         
     | 
| 
      
 84 
     | 
    
         
            +
            require_paths: 
         
     | 
| 
      
 85 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 86 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 87 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 88 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 89 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 90 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 91 
     | 
    
         
            +
                  hash: 3
         
     | 
| 
      
 92 
     | 
    
         
            +
                  segments: 
         
     | 
| 
      
 93 
     | 
    
         
            +
                  - 0
         
     | 
| 
      
 94 
     | 
    
         
            +
                  version: "0"
         
     | 
| 
      
 95 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 96 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 97 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 98 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 99 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 100 
     | 
    
         
            +
                  hash: 3
         
     | 
| 
      
 101 
     | 
    
         
            +
                  segments: 
         
     | 
| 
      
 102 
     | 
    
         
            +
                  - 0
         
     | 
| 
      
 103 
     | 
    
         
            +
                  version: "0"
         
     | 
| 
      
 104 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
      
 106 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 107 
     | 
    
         
            +
            rubygems_version: 1.3.7
         
     | 
| 
      
 108 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 109 
     | 
    
         
            +
            specification_version: 3
         
     | 
| 
      
 110 
     | 
    
         
            +
            summary: An improved Logger replacement that logs to syslog. It is almost drop-in with a few caveats.
         
     | 
| 
      
 111 
     | 
    
         
            +
            test_files: 
         
     | 
| 
      
 112 
     | 
    
         
            +
            - test/helper.rb
         
     | 
| 
      
 113 
     | 
    
         
            +
            - test/test_syslog_logger.rb
         
     |