<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -54,6 +54,6 @@ opts.parse!
 
 EM.run do
   Nanite.start_mapper(options)
-  puts &quot;starting nanite-admin&quot;
+  Nanite::Log.info &quot;starting nanite-admin&quot;
   Rack::Handler::Thin.run(Nanite::Admin.new(Nanite.mapper), :Port =&gt; 4000)
 end
\ No newline at end of file</diff>
      <filename>bin/nanite-admin</filename>
    </modified>
    <modified>
      <diff>@@ -1,15 +1,14 @@
 module Nanite
   class ActorRegistry
-    attr_reader :actors, :log
+    attr_reader :actors
 
-    def initialize(log)
-      @log = log
+    def initialize
       @actors = {}
     end
 
     def register(actor, prefix)
       raise ArgumentError, &quot;#{actor.inspect} is not a Nanite::Actor subclass instance&quot; unless Nanite::Actor === actor
-      log.info(&quot;Registering #{actor.inspect} with prefix #{prefix.inspect}&quot;)
+      Nanite::Log.info(&quot;Registering #{actor.inspect} with prefix #{prefix.inspect}&quot;)
       prefix ||= actor.class.default_prefix
       actors[prefix.to_s] = actor
     end</diff>
      <filename>lib/nanite/actor_registry.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,7 +5,7 @@ module Nanite
     include ConsoleHelper
     include DaemonizeHelper
 
-    attr_reader :identity, :log, :options, :serializer, :dispatcher, :registry, :amq
+    attr_reader :identity, :options, :serializer, :dispatcher, :registry, :amq
     attr_accessor :status_proc
 
     DEFAULT_OPTIONS = COMMON_DEFAULT_OPTIONS.merge({:user =&gt; 'nanite', :ping_time =&gt; 15,
@@ -73,13 +73,18 @@ module Nanite
 
     def initialize(opts)
       set_configuration(opts)
-      @log = Log.new(@options, @identity)
+      log_path = false
+      if @options[:daemonize]
+        log_path = (@options[:log_dir] || @options[:root] || Dir.pwd)
+      end
+      Log.init(@identity, log_path)
+      Log.log_level = @options[:log_level] || :info
       @serializer = Serializer.new(@options[:format])
       @status_proc = lambda { parse_uptime(`uptime`) rescue 'no status' }
       daemonize if @options[:daemonize]
       @amq = start_amqp(@options)
-      @registry = ActorRegistry.new(@log)
-      @dispatcher = Dispatcher.new(@amq, @registry, @serializer, @identity, @log, @options)
+      @registry = ActorRegistry.new
+      @dispatcher = Dispatcher.new(@amq, @registry, @serializer, @identity, @options)
       load_actors
       setup_queue
       advertise_services
@@ -116,7 +121,7 @@ module Nanite
     def load_actors
       return unless options[:root]
       Dir[&quot;#{options[:root]}/actors/*.rb&quot;].each do |actor|
-        log.info(&quot;loading actor: #{actor}&quot;)
+        Nanite::Log.info(&quot;loading actor: #{actor}&quot;)
         require actor
       end
       init_path = File.join(options[:root], 'init.rb')
@@ -127,10 +132,10 @@ module Nanite
       packet = serializer.load(packet)
       case packet
       when Advertise
-        log.debug(&quot;handling Advertise: #{packet}&quot;)
+        Nanite::Log.debug(&quot;handling Advertise: #{packet}&quot;)
         advertise_services
       when Request, Push
-        log.debug(&quot;handling Request: #{packet}&quot;)
+        Nanite::Log.debug(&quot;handling Request: #{packet}&quot;)
         dispatcher.dispatch(packet)
       end
     end
@@ -149,7 +154,7 @@ module Nanite
     end
 
     def advertise_services
-      log.debug(&quot;advertise_services: #{registry.services.inspect}&quot;)
+      Nanite::Log.debug(&quot;advertise_services: #{registry.services.inspect}&quot;)
       amq.fanout('registration', :no_declare =&gt; options[:secure]).publish(serializer.dump(Register.new(identity, registry.services, status_proc.call)))
     end
 </diff>
      <filename>lib/nanite/agent.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,15 +1,14 @@
 module Nanite
   class Cluster
-    attr_reader :agent_timeout, :nanites, :reaper, :log, :serializer, :identity, :amq
+    attr_reader :agent_timeout, :nanites, :reaper, :serializer, :identity, :amq
 
-    def initialize(amq, agent_timeout, identity, log, serializer)
+    def initialize(amq, agent_timeout, identity, serializer)
       @amq = amq
       @agent_timeout = agent_timeout
       @identity = identity
       @serializer = serializer
       @nanites = {}
       @reaper = Reaper.new(agent_timeout)
-      @log = log
       setup_queues
     end
 
@@ -25,7 +24,7 @@ module Nanite
     def register(reg)
       nanites[reg.identity] = { :services =&gt; reg.services, :status =&gt; reg.status }
       reaper.timeout(reg.identity, agent_timeout + 1) { nanites.delete(reg.identity) }
-      log.info(&quot;registered: #{reg.identity}, #{nanites[reg.identity]}&quot;)
+      Nanite::Log.info(&quot;registered: #{reg.identity}, #{nanites[reg.identity]}&quot;)
     end
 
     def route(request, targets)
@@ -95,14 +94,14 @@ module Nanite
 
     def setup_heartbeat_queue
       amq.queue(&quot;heartbeat-#{identity}&quot;, :exclusive =&gt; true).bind(amq.fanout('heartbeat', :durable =&gt; true)).subscribe do |ping|
-        log.debug('got heartbeat')
+        Nanite::Log.debug('got heartbeat')
         handle_ping(serializer.load(ping))
       end
     end
 
     def setup_registration_queue
       amq.queue(&quot;registration-#{identity}&quot;, :exclusive =&gt; true).bind(amq.fanout('registration', :durable =&gt; true)).subscribe do |msg|
-        log.debug('got registration')
+        Nanite::Log.debug('got registration')
         register(serializer.load(msg))
       end
     end</diff>
      <filename>lib/nanite/cluster.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,9 +4,9 @@ module Nanite
       exit if fork
       Process.setsid
       exit if fork
-      $stdin.reopen(&quot;/dev/null&quot;)
-      $stdout.reopen(log.file, &quot;a&quot;)
-      $stderr.reopen($stdout)
+      #$stdin.reopen(&quot;/dev/null&quot;)
+      #$stdout.reopen(log.file, &quot;a&quot;)
+      #$stderr.reopen($stdout)
     end
   end
 end
\ No newline at end of file</diff>
      <filename>lib/nanite/daemonize.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,13 +1,12 @@
 module Nanite
   class Dispatcher
-    attr_reader :registry, :serializer, :identity, :log, :amq, :options
+    attr_reader :registry, :serializer, :identity, :amq, :options
 
-    def initialize(amq, registry, serializer, identity, log, options)
+    def initialize(amq, registry, serializer, identity, options)
       @amq = amq
       @registry = registry
       @serializer = serializer
       @identity = identity
-      @log = log
       @options = options
     end
 
@@ -36,7 +35,7 @@ module Nanite
 
     def handle_exception(actor, meth, deliverable, e)
       error = describe_error(e)
-      log.error(error)
+      Nanite::Log.error(error)
       begin
         if actor.class.instance_exception_callback
           case actor.class.instance_exception_callback
@@ -51,7 +50,7 @@ module Nanite
         end
       rescue Exception =&gt; e1
         error = describe_error(e1)
-        log.error(error)
+        Nanite::Log.error(error)
       end
       error
     end</diff>
      <filename>lib/nanite/dispatcher.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,10 +1,9 @@
 module Nanite
   class JobWarden
-    attr_reader :serializer, :jobs, :log
+    attr_reader :serializer, :jobs
 
-    def initialize(serializer, log)
+    def initialize(serializer)
       @serializer = serializer
-      @log = log
       @jobs = {}
     end
 
@@ -16,7 +15,7 @@ module Nanite
 
     def process(msg)
       msg = serializer.load(msg)
-      log.debug(&quot;processing message: #{msg.inspect}&quot;)
+      Nanite::Log.debug(&quot;processing message: #{msg.inspect}&quot;)
       if job = jobs[msg.token]
         job.process(msg)
         if job.completed?</diff>
      <filename>lib/nanite/job.rb</filename>
    </modified>
    <modified>
      <diff>@@ -17,13 +17,13 @@ module Nanite
       # If this method is called with no arguments, it will log to STDOUT at the :info level.
       #
       # It also configures the Logger instance it creates to use the custom Nanite::Log::Formatter class.
-      def init(*opts)
-        if opts.length == 0
-          @logger = Logger.new(STDOUT)
-        else
-          @logger = Logger.new(*opts)
+      def init(identity, path = false)
+        @file = STDOUT
+        if path
+          @file = File.join(path, &quot;nanite.#{identity}.log&quot;)
         end
-        @logger.formatter = Nanite::Log::Formatter.new()
+        @logger = Logger.new(@file)
+        @logger.formatter = Nanite::Log::Formatter.new
         level(@log_level = :info)
       end
       
@@ -58,7 +58,7 @@ module Nanite
       # this method gets hit before a call to Nanite::Logger.init has been made, it will call 
       # Nanite::Logger.init() with no arguments.
       def method_missing(method_symbol, *args)
-        init() unless @logger
+        init(identity) unless @logger
         if args.length &gt; 0
           @logger.send(method_symbol, *args)
         else</diff>
      <filename>lib/nanite/log.rb</filename>
    </modified>
    <modified>
      <diff>@@ -21,7 +21,7 @@ module Nanite
     include ConsoleHelper
     include DaemonizeHelper
 
-    attr_reader :cluster, :identity, :job_warden, :options, :serializer, :log, :amq
+    attr_reader :cluster, :identity, :job_warden, :options, :serializer, :amq
 
     DEFAULT_OPTIONS = COMMON_DEFAULT_OPTIONS.merge({:user =&gt; 'mapper', :identity =&gt; Identity.generate, :agent_timeout =&gt; 15,
       :offline_redelivery_frequency =&gt; 10, :persistent =&gt; false, :offline_failsafe =&gt; false}) unless defined?(DEFAULT_OPTIONS)
@@ -83,15 +83,30 @@ module Nanite
     end
 
     def initialize(options)
-      @options = DEFAULT_OPTIONS.merge(options)
+      @options = DEFAULT_OPTIONS.clone.merge(options)
+      root = options[:root] || @options[:root]
+      custom_config = if root
+        file = File.expand_path(File.join(root, 'config.yml'))
+        File.exists?(file) ? (YAML.load(IO.read(file)) || {}) : {}
+      else
+        {}
+      end
+      options.delete(:identity) unless options[:identity]
+      @options.update(custom_config.merge(options))
       @identity = &quot;mapper-#{@options[:identity]}&quot;
-      @log = Log.new(@options, @identity)
+      @options[:file_root] ||= File.join(@options[:root], 'files')
+      log_path = false
+      if @options[:daemonize]
+        log_path = (@options[:log_dir] || @options[:root] || Dir.pwd)
+      end
+      Log.init(@identity, log_path)
+      Log.log_level = @options[:log_level]
       @serializer = Serializer.new(@options[:format])
       daemonize if @options[:daemonize]
-      @amq =start_amqp(@options)
-      @cluster = Cluster.new(@amq, @options[:agent_timeout], @options[:identity], @log, @serializer)
-      @job_warden = JobWarden.new(@serializer, @log)
-      @log.info('starting mapper')
+      @amq = start_amqp(@options)
+      @cluster = Cluster.new(@amq, @options[:agent_timeout], @options[:identity], @serializer)
+      @job_warden = JobWarden.new(@serializer)
+      Nanite::Log.info('starting mapper')
       setup_queues
       start_console if @options[:console] &amp;&amp; !@options[:daemonize]
     end</diff>
      <filename>lib/nanite/mapper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -89,14 +89,14 @@ module Nanite
       def handle_packet(packet)
         case packet
         when Nanite::FileChunk
-          log.debug &quot;written chunk to #{@dest.inspect}&quot;
+          Nanite::Log.debug &quot;written chunk to #{@dest.inspect}&quot;
           @data &lt;&lt; packet.chunk
         
           if @write
             @dest.write(packet.chunk)
           end
         when Nanite::FileEnd
-          log.debug &quot;#{@dest.inspect} receiving is completed&quot;
+          Nanite::Log.debug &quot;#{@dest.inspect} receiving is completed&quot;
           if @write
             @dest.close
           end
@@ -108,7 +108,7 @@ module Nanite
     end
 
     def subscribe_to_files(domain='global', write=false, &amp;blk)
-      log.info &quot;subscribing to file broadcasts for #{domain}&quot;
+      Nanite::Log.info &quot;subscribing to file broadcasts for #{domain}&quot;
       @files ||= {}
       amq.queue(&quot;files#{domain}&quot;).bind(amq.topic('file broadcast'), :key =&gt; &quot;nanite.filepeer.#{domain}&quot;).subscribe do |packet|
         case msg = load_packet(packet)</diff>
      <filename>lib/nanite/streaming.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>c6af46d9d747550bcb21adb88c6744bc73a5ede0</id>
    </parent>
  </parents>
  <author>
    <name>Benjamin Black</name>
    <email>bb@joyeuse.local</email>
  </author>
  <url>http://github.com/ezmobius/nanite/commit/122bdbe30fce7848fabb88b139bc1144c6b430de</url>
  <id>122bdbe30fce7848fabb88b139bc1144c6b430de</id>
  <committed-date>2009-03-05T15:35:42-08:00</committed-date>
  <authored-date>2009-03-05T15:35:42-08:00</authored-date>
  <message>[central_logger] updated everything for central logging.  thin still chatty, though.</message>
  <tree>0fb52d3b275f20eb79e30edee6ac5427429b248e</tree>
  <committer>
    <name>Benjamin Black</name>
    <email>bb@joyeuse.local</email>
  </committer>
</commit>
