Sha256: 5de6cf1a0b5f7514b41f0ad7c646caf7b2681996a502c267b79d63672fd5f3c9

Contents?: true

Size: 614 Bytes

Versions: 4

Compression:

Stored size: 614 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
      
      def log_error(e)
        trace { "#{e}\n\t" + e.backtrace.join("\n\t") }
      end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
thin-0.6.0-x86-mswin32-60 lib/thin/logging.rb
thin-0.6.0 lib/thin/logging.rb
thin-0.6.1-x86-mswin32-60 lib/thin/logging.rb
thin-0.6.1 lib/thin/logging.rb