Module PhusionPassenger::DebugLogging |
In: | lib/phusion_passenger/debug_logging.rb

Methods

- _log_device
- debug
- error
- included
- log_file=
- log_level=
- stderr_evaluator=
- trace
- warn

Public Class methods
_log_device()

[ show source ]

        # File lib/phusion_passenger/debug_logging.rb, line 55
    55:         def self._log_device
    56:                 return @@log_device
    57:         end

included(klass)

[ show source ]

        # File lib/phusion_passenger/debug_logging.rb, line 34
    34:         def self.included(klass)
    35:                 klass.class_eval do
    36:                         private :debug
    37:                         private :trace
    38:                 end
    39:         end

log_file=(filename)

[ show source ]

        # File lib/phusion_passenger/debug_logging.rb, line 45
    45:         def self.log_file=(filename)
    46:                 if filename && filename.empty?
    47:                         @@log_filename = nil
    48:                 else
    49:                         @@log_filename = filename
    50:                 end
    51:                 @@log_device.close if @@log_device && !@@log_device.closed?
    52:                 @@log_device = nil
    53:         end

log_level=(level)

[ show source ]

        # File lib/phusion_passenger/debug_logging.rb, line 41
    41:         def self.log_level=(level)
    42:                 @@log_level = level
    43:         end

stderr_evaluator=(block)

[ show source ]

        # File lib/phusion_passenger/debug_logging.rb, line 59
    59:         def self.stderr_evaluator=(block)
    60:                 if block
    61:                         @@stderr_evaluator = block
    62:                 else
    63:                         @@stderr_evaluator = lambda { STDERR }
    64:                 end
    65:         end

Public Instance methods
debug(message)

[ show source ]

        # File lib/phusion_passenger/debug_logging.rb, line 77
    77:         def debug(message)
    78:                 trace(1, message, 1)
    79:         end

error(message)

[ show source ]

        # File lib/phusion_passenger/debug_logging.rb, line 67
    67:         def error(message)
    68:                 trace(-1, message, 1)
    69:         end

trace(level, message, nesting_level = 0)

[ show source ]

         # File lib/phusion_passenger/debug_logging.rb, line 82
     82:         def trace(level, message, nesting_level = 0)
     83:                 if @@log_level >= level
     84:                         if @@log_filename
     85:                                 if !@@log_device || @@log_device.closed?
     86:                                         @@log_device = File.open(@@log_filename, "a")
     87:                                 end
     88:                                 output = @@log_device
     89:                         else
     90:                                 output = @@stderr_evaluator.call
     91:                         end
     92:                         location = caller[nesting_level].sub(/.*phusion_passenger\//, '')
     93:                         location.sub!(/(.*):.*/, '\1')
     94:                         now = Time.now
     95:                         time_str = now.strftime("%Y-%m-%d %H:%M:%S.")
     96:                         time_str << sprintf("%03d", now.usec / 1000)
     97:                         output.write("[ pid=#{$$} thr=#{Thread.current.object_id} file=#{location} time=#{time_str} ]: #{message}\n")
     98:                         output.flush
     99:                 end
    100:         end

warn(message)

[ show source ]

        # File lib/phusion_passenger/debug_logging.rb, line 72
    72:         def warn(message)
    73:                 trace(0, message, 1)
    74:         end