Sha256: 24cd40f49fd5d58f0267f012b43e5bb0ce921ff809bcade877c048575cf99429

Contents?: true

Size: 1.33 KB

Versions: 10

Compression:

Stored size: 1.33 KB

Contents

require 'omf_common/lobject'

module Thin
  # Overwrite thin's logging mix-in to work more nicely 
  # with log4r
  #
  module Logging
    class << self
      attr_writer :trace, :debug, :silent
      
      def trace?;  !@silent && @trace  end
      def debug?;  !@silent && @debug  end
      def silent?;  @silent            end
    end
    
    # # Global silencer methods
    # def silent
      # Logging.silent?
    # end
    # def silent=(value)
      # Logging.silent = value
    # end
    
    # Log a message to the console
    def log(msg)
      (@logger ||= OMF::Common::LObject.new(self.class)).info(msg)
    end
    module_function :log
    public :log
    
    # Log a message to the console if tracing is activated
    def trace(msg=nil)
      return unless msg      
      (@logger ||= OMF::Common::LObject.new(self.class)).debug(msg)
    end
    module_function :trace
    public :trace
    
    # Log a message to the console if debugging is activated
    def debug(msg=nil)
      return unless msg
      (@logger ||= OMF::Common::LObject.new(self.class)).debug(msg)
    end
    module_function :debug
    public :debug
    
    # Log an error backtrace if debugging is activated
    def log_error(e = $!)
      (@logger ||= OMF::Common::LObject.new(self.class)).error(e)
    end
    module_function :log_error
    public :log_error
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
omf_web-1.0.0 lib/omf-web/thin/logging.rb
omf_web-0.9.9 lib/omf-web/thin/logging.rb
omf_web-0.9.8 lib/omf-web/thin/logging.rb
omf_web-0.9.7 lib/omf-web/thin/logging.rb
omf_web-0.9.6 lib/omf-web/thin/logging.rb
omf_web-0.9.5 lib/omf-web/thin/logging.rb
omf_web-0.9.4 lib/omf-web/thin/logging.rb
omf_web-0.9.3 lib/omf-web/thin/logging.rb
omf_web-0.9.1 lib/omf-web/thin/logging.rb
omf_web-0.9 lib/omf-web/thin/logging.rb