Changeset 915

Show
Ignore:
Timestamp:
12/16/07 15:50:51 (8 months ago)
Author:
wayneeseguin
Message:

One step in the right direction.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Manifest

    r864 r915  
    3838lib/mongrel/http_response.rb 
    3939lib/mongrel/init.rb 
     40lib/mongrel/logger.rb 
    4041lib/mongrel/mime_types.yml 
    4142lib/mongrel/rails.rb 
  • trunk/TODO

    r910 r915  
    11 
    22* Rewrite and merge mongrel cluster and mongrel_rails into something small and maintainable. 
    3 * Refactor logging to include timestamps. 
    4 * See if Java is setting the server version string in the request properly. 
    5 * Figure out why Java writes to STDERR instead of the file in the middle of one of the tests. 
    6 * Remove cgi_multipart_eof_fix and fastthread permanently (for 1.2). 
  • trunk/lib/mongrel.rb

    r902 r915  
    7070    attr_reader :num_processors 
    7171 
     72    attr_accessor :logger 
     73 
    7274    # Creates a working server on host:port (strange things happen if port isn't a Number). 
    7375    # Use HttpServer::run to start the server and HttpServer.acceptor.join to  
     
    8385    # socket.accept calls in order to give the server a cheap throttle time.  It defaults to 0 and 
    8486    # actually if it is 0 then the sleep is not done at all. 
    85     def initialize(host, port, num_processors=950, throttle=0, timeout=60, log=nil
     87    def initialize(host, port, num_processors=950, throttle=0, timeout=60, log=nil, log_level=:debug
    8688       
    8789      tries = 0 
     
    9597      @num_processors = num_processors 
    9698      @timeout = timeout 
    97       Mongrel::Logger = Mongrel::Log.new(log || "mongrel-#{port}.log") 
     99      # Mongrel.logger = Mongrel::Log.new(log || "mongrel-#{port}.log") 
     100      @logger = Mongrel::Log.new(log || "mongrel-#{port}.log", log_level) 
    98101    end 
    99102 
  • trunk/lib/mongrel/configurator.rb

    r899 r915  
    250250 
    251251      # check all the mime types to make sure they are the right format 
    252       mime.each {|k,v| log(, "WARNING: MIME type #{k} must start with '.'") if k.index(".") != 0 } 
     252      mime.each {|k,v| log(:warning, "WARNING: MIME type #{k} must start with '.'") if k.index(".") != 0 } 
    253253 
    254254      return mime 
     
    362362 
    363363      # forced shutdown, even if previously restarted (actually just like TERM but for CTRL-C) 
    364       trap("INT") { log(:notice, "INT signal received."; stop(false) } 
     364      trap("INT") { log(:notice, "INT signal received."); stop(false) } 
    365365 
    366366      # always clean up the pid file 
     
    369369      unless RUBY_PLATFORM =~ /djgpp|(cyg|ms|bcc)win|mingw/ 
    370370        # graceful shutdown 
    371         trap("TERM") { log(:notice, "TERM signal received."; stop)
     371        trap("TERM") { log(:notice, "TERM signal received."); stop
    372372        # debug mode 
    373         trap("USR1") { log(:notice, "USR1 received, toggling $mongrel_debug_client to #{!$mongrel_debug_client}"; $mongrel_debug_client = !$mongrel_debug_client)
     373        trap("USR1") { log(:notice, "USR1 received, toggling $mongrel_debug_client to #{!$mongrel_debug_client}"); $mongrel_debug_client = !$mongrel_debug_client
    374374        # restart 
    375         trap("USR2") { log(:notice, "USR2 signal received."; stop(true)) } 
     375        trap("USR2") { log(:notice, "USR2 signal received."); stop(true) } 
    376376 
    377377        log(:notice, "Signals ready.  TERM => stop.  USR2 => restart.  INT => stop (no restart).") 
  • trunk/lib/mongrel/logger.rb

    r905 r915  
    33#       Merb:  http://merbivore.com 
    44module Mongrel 
     5 
     6  #class << self 
     7  #  attr_accessor :logger 
     8  #end 
    59 
    610  class Log 
     
    1317    } 
    1418     
    15     def initialize(log, log_level
     19    def initialize(log, log_level = :debug
    1620      @logger    = initialize_io(log) 
    1721      @log_level = Levels[:name][log_level] 
     
    5761  # Convenience wrapper for logging, allows us to use Mongrel.log 
    5862  def self.log(level, string) 
    59     Mongrel::Logger.log(level,string) 
     63    logger.log(level,string) 
    6064  end 
    6165