Sha256: 707e502d2c18db74f0421eb4e71e8b5b4d0a39c583ff555bfd619b95215f32f8

Contents?: true

Size: 669 Bytes

Versions: 6

Compression:

Stored size: 669 Bytes

Contents

module Thin
  # To be included into classes to allow some basic logging
  # that can be silented (+silent+) or made more verbose ($DEBUG=true).
  module Logging
    # Don't output any message if +true+.
    attr_accessor :silent
    
    protected
      # Log a message to the console
      def log(msg)
        puts msg unless @silent
      end
      
      # Log a message to the console if tracing is activated
      def trace(msg=nil)
        puts msg || yield if ($DEBUG || $TRACE) && !@silent
      end
      
      # Log an error backtrace if tracing is activated
      def log_error(e)
        trace { "#{e}\n\t" + e.backtrace.join("\n\t") }
      end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
thin-0.6.3 lib/thin/logging.rb
thin-0.6.2-x86-mswin32-60 lib/thin/logging.rb
thin-0.6.3-x86-mswin32-60 lib/thin/logging.rb
thin-0.6.4-x86-mswin32-60 lib/thin/logging.rb
thin-0.6.4 lib/thin/logging.rb
thin-0.6.2 lib/thin/logging.rb