<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,29 +1,32 @@
+# This isn't technically a Bundler gemfile anymore...
+# To install these gems, run bin/install_gems
+
 merb_gems_version = &quot;1.1&quot;
 dm_gems_version   = &quot;0.10.1&quot;
 do_gems_version   = &quot;0.10.0&quot;
 
 # Set bundle path to ./gems. use the &quot;gem bundle&quot; command to generate the bundle
-bundle_path(&quot;tmp/&quot; + RUBY_RELEASE_DATE)
-source &quot;http://edge.merbivore.com&quot;
-
-gem &quot;merb-core&quot;,        merb_gems_version
-gem &quot;merb-assets&quot;,      merb_gems_version
-gem &quot;merb-cache&quot;,       merb_gems_version
-gem &quot;merb-haml&quot;,        merb_gems_version
-gem &quot;merb-mailer&quot;,      merb_gems_version
-gem &quot;merb-exceptions&quot;,  merb_gems_version
+#bundle_path(&quot;tmp/&quot; + RUBY_RELEASE_DATE)
+#source &quot;http://edge.merbivore.com&quot;
 
 gem &quot;memcache-client&quot;, &quot;1.7.5&quot;, :require_as =&gt; []
 gem &quot;curb&quot;, &quot;0.5.4.0&quot;
 gem &quot;nokogiri&quot;, &quot;1.3.3&quot;
-gem &quot;gchartrb&quot;, :require_as =&gt; &quot;google_chart&quot;
+gem &quot;gchartrb&quot;, nil, :require_as =&gt; &quot;google_chart&quot;
 gem &quot;sinatra&quot;, &quot;0.9.4&quot;
-gem &quot;mime-types&quot;, :require_as =&gt; &quot;mime/types&quot;
+gem &quot;mime-types&quot;, nil, :require_as =&gt; &quot;mime/types&quot;
 gem &quot;moneta&quot;, &quot;0.6.0&quot;
 
-only :test do
+gem &quot;merb-core&quot;,        merb_gems_version, :source =&gt; &quot;http://edge.merbivore.com&quot;
+gem &quot;merb-assets&quot;,      merb_gems_version, :source =&gt; &quot;http://edge.merbivore.com&quot;
+gem &quot;merb-cache&quot;,       merb_gems_version, :source =&gt; &quot;http://edge.merbivore.com&quot;
+gem &quot;merb-haml&quot;,        merb_gems_version, :source =&gt; &quot;http://edge.merbivore.com&quot;
+gem &quot;merb-mailer&quot;,      merb_gems_version, :source =&gt; &quot;http://edge.merbivore.com&quot;
+gem &quot;merb-exceptions&quot;,  merb_gems_version, :source =&gt; &quot;http://edge.merbivore.com&quot;
+
+#only :test do
   gem &quot;thin&quot;
   gem &quot;rake&quot;
   gem &quot;webrat&quot;
-  gem &quot;rspec&quot;, :require_as =&gt; []
-end
+  gem &quot;rspec&quot;
+#end</diff>
      <filename>Gemfile</filename>
    </modified>
    <modified>
      <diff>@@ -7,16 +7,16 @@ class Application &lt; Merb::Controller
   before :no_language_domain
   include ControllerExtensions::Logging
   include ControllerExtensions::Accessors
-  
+
  protected
-  
+
   def no_language_domain
     if request.language_code == &quot;m&quot;
       language_code = (request.env[&quot;HTTP_ACCEPT_LANGUAGE&quot;] || &quot;en&quot;)[0..1] || &quot;en&quot;
       throw :halt, redirect(&quot;http://#{language_code}.#{request.host}&quot;)
     end
   end
-  
+
   # Override in each controller for better control
   def current_name
     @title || &quot;Wikipedia&quot;</diff>
      <filename>app/controllers/application.rb</filename>
    </modified>
    <modified>
      <diff>@@ -71,7 +71,8 @@ class Articles &lt; Application
  private 
  
   def format_display_with_data(html = nil, &amp;block)
-    Merb.logger.debug(&quot;CTYPE: #{content_type}&quot;)
+    Merb.logger[:content_type] = content_type
+
     case content_type
     when :json
       json = JSON.dump(block.call)
@@ -101,7 +102,7 @@ class Articles &lt; Application
         Merb.logger.debug(&quot;KEY: #{key}&quot;)
       
         if html
-          Merb.logger.debug(&quot;CACHE HIT&quot;)
+          Merb.logger[:cache_hit] = true
           return html
         else
           html = block.call
@@ -110,7 +111,7 @@ class Articles &lt; Application
             Cache.store(key, html, :expires_in =&gt; 60 * 60 * 12)
           end
 
-          Merb.logger.debug(&quot;CACHE MISS&quot;)
+          Merb.logger[:cache_hit] = false
         end
         html
       end</diff>
      <filename>app/controllers/articles.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,24 +1,42 @@
 module ControllerExtensions
   module Logging
     def self.included(klass)
-      klass.before :logger_output
+      klass.before :start_timer
+      klass.after :logger_output
       
       # DEVELOPMENT
       if Merb.env == &quot;development&quot;
-        klass.before :debug_output
         klass.before :clear_cache
       end
     end
+    
+    def start_timer
+      @timer = Time.now
+    end
 
     def logger_output
-      Merb.logger.info(&quot;ReqLogger #{Time.now.to_s} (#{request.language_code}) #{params[:controller]}/#{params[:action]} | #{request.user_agent} | #{request.device.format_name} | #{request.remote_ip} | #{request.referer}&quot;)
-    end
-    
-    def debug_output
-      Merb.logger.debug(&quot;User Agent: &quot; + request.user_agent)
-      Merb.logger.debug(&quot;Format: &quot; + request.device.format_name.to_s)
-      Merb.logger.debug(&quot;Language Code: &quot; + request.language_code)
-      Merb.logger.debug(&quot;Accepts: &quot; + request.accept)
+      logged_data = {:time =&gt; Time.now.to_s, 
+                     :action_time =&gt; (Time.now - @timer),
+                     :language_code =&gt; request.language_code, 
+                     :country_code =&gt; request.country_code,
+                     :user_agent =&gt; request.user_agent,
+                     :referer =&gt; request.referer,
+                     :format_name =&gt; request.device.format_name,
+                     :was_redirected =&gt; params[:wasRedirected],
+                     :was_home_page =&gt; (params[:action] == &quot;home&quot;)
+                     }
+
+      if @article
+        logged_data[:article_title] = @article.title
+      end
+
+      # This is an extension that we added to logger
+      logged_data.merge!(Merb.logger.dump_logger_hash)
+
+      # Dump it out!
+      yaml = logged_data.to_yaml
+      yaml_flat = yaml.gsub(&quot;\n&quot;, &quot;\\n&quot;)
+      Merb.logger.warn(&quot;~~~~&quot; + yaml_flat)
     end
 
     def clear_cache</diff>
      <filename>app/controllers/extensions/logging.rb</filename>
    </modified>
    <modified>
      <diff>@@ -21,7 +21,7 @@ class Article &lt; Wikipedia::Resource
   def has_search_results?
     if (@html = Cache[key])
       Merb.logger.debug(&quot;KEY: #{key}&quot;)
-      Merb.logger.debug(&quot;CACHE HIT&quot;)
+      Merb.logger[:cache_hit] = true
       return false
     else
       fetch! if raw_html.nil?
@@ -50,17 +50,17 @@ class Article &lt; Wikipedia::Resource
     time_to &quot;lookup in cache&quot; do
       Merb.logger.debug(&quot;KEY: #{key}&quot;)
       if (@html = Cache[key])
-        Merb.logger.debug(&quot;CACHE HIT&quot;)
+        Merb.logger[:cache_hit] = true
         return @html.force_encoding(&quot;UTF-8&quot;)
       else
-        Merb.logger.debug(&quot;CACHE MISS&quot;)
+        Merb.logger[:cache_hit] = false
       end
     end
 
     # Grab the html from the server object
     fetch! if raw_html.nil?
 
-    time_to &quot;parse #{device}&quot; do
+    time_to &quot;parse and modify xml&quot; do
       # Figure out if we need to do extra formatting...
       case device.parser
       when &quot;html&quot;</diff>
      <filename>app/models/article.rb</filename>
    </modified>
    <modified>
      <diff>@@ -38,28 +38,25 @@ class Server
     paths.each do |path|
       result = nil
 
-      Merb.logger.debug(&quot;loading... &quot; + base_url + path)
-
       result = fetch_from_web(path)
       
 
       compressed_size = result.downloaded_content_length
 
-      Merb.logger.debug(&quot;loaded #{result.downloaded_content_length} compressed characters&quot;)
+      Merb.logger[:gzipped_raw_article_content_length] = result.downloaded_content_length
 
       if result.response_code == 200
         
         if result.header_str.include?(&quot;Cache-Lookup: HIT&quot;)
-          Merb.logger.debug(&quot;Spider HIT&quot;)
+          Merb.logger[:wikipedia_cache_hit] = true
         else
-          Merb.logger.debug(&quot;Spider MISS&quot;)
+          Merb.logger[:wikipedia_cache_hit] = false
         end
 
         body = nil
-        
-        
-        time_to &quot;decompress&quot; do
-          
+
+        time_to &quot;decompress downloaded article&quot; do
+
           begin 
             gz = Zlib::GzipReader.new( StringIO.new( result.body_str ) )
             body = gz.read
@@ -71,7 +68,7 @@ class Server
           body = body.force_encoding(&quot;UTF-8&quot;)
         end
         
-        Merb.logger.debug(&quot;Decompressed to #{body.size} characters&quot;)
+        Merb.logger[:raw_article_content_length] = body.size
         
         return {:url =&gt; result.last_effective_url, :body =&gt; body} 
       end
@@ -84,7 +81,7 @@ class Server
 
   # :api: private
   def fetch_from_web(path)
-    time_to &quot;fetch&quot; do
+    time_to &quot;download article from web&quot; do
       if defined?(Curl)
         begin
           Curl::Easy.perform(base_url + path) do |curl|</diff>
      <filename>app/models/server.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,3 @@
 .message.notice
-  Wikipedia Mobile needs your help---
+  US-Users
   %a{:href =&gt; &quot;/donate&quot;} find out how you can help!</diff>
      <filename>app/views/notices/_donate.html.haml</filename>
    </modified>
    <modified>
      <diff>@@ -2,7 +2,7 @@ Merb.logger.info(&quot;Loaded PRODUCTION Environment...&quot;)
 Merb::Config.use { |c|
   c[:exception_details] = false
   c[:reload_classes] = false
-  c[:log_level] = :debug
+  c[:log_level] = :warn
   c[:default_cookie_domain] = &quot;.wikipedia.org&quot;
   
   c[:log_file]  = Merb.root / &quot;log&quot; / &quot;production.log&quot;</diff>
      <filename>config/environments/production.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,7 +2,8 @@ class Object
   def time_to(thing, &amp;block)
     start_time = Time.now
     result = block.call
-    Merb.logger.debug(&quot;#{thing} took &quot; + (Time.now - start_time).to_s + &quot; seconds&quot;)
+    Merb.logger[:time_to] ||= {}
+    Merb.logger[:time_to][thing] = (Time.now - start_time)
     return result
   end
 end
\ No newline at end of file</diff>
      <filename>lib/object.rb</filename>
    </modified>
    <modified>
      <diff>@@ -14,8 +14,8 @@ class StatSegment
   extend StatMerging::ClassMethods
   
   property :id, Serial
-  property :time, Time, :indexed =&gt; true
-  property :time_length, String, :indexed =&gt; true
+  property :time, Time, :index =&gt; true
+  property :time_length, String, :index =&gt; true
   property :cache_hit_ratio, Float
   property :spider_cache_hit_ratio, Float
   property :hits, Integer
@@ -28,6 +28,9 @@ class StatSegment
   property :median_action_time, Float, :default =&gt; 0.0
   property :language_hits, Object, :lazy =&gt; false
   property :format_hits, Object, :lazy =&gt; false
+  property :country_hits, Object, :lazy =&gt; false
+  property :user_agent_hits, Object, :lazy =&gt; false
+  property :content_type_hits, Object, :lazy =&gt; false
   property :cache_size, Integer
   property :load_average, Float
   </diff>
      <filename>stats/models/stat.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,121 +5,127 @@ trap(&quot;USR1&quot;) {
 
 def run_parser(path)
   log_file = File::join(path, &quot;log&quot;, &quot;production.log&quot;)
-  file = log_file + &quot;.&quot; + Time.now.to_i.to_s
+  file = log_file #+ &quot;.&quot; + Time.now.to_i.to_s
 
-  `mv #{log_file} #{file}`
-  `pkill -USR1 thin`
+  #{}`mv #{log_file} #{file}`
+  #{}`pkill -USR1 thin`
 
-  stats = StatSegment.new(:time =&gt; Time.now, :time_length =&gt; &quot;minute&quot;)
+  stat = Stat.new(:time =&gt; Time.now, :time_length =&gt; &quot;minute&quot;)
   
   ## ====================== LANGUAGE AND FORMAT =================================
 
-  languages = {}
-  formats  = {}
-  hits = `cat #{file} | grep ReqLogger | wc`.split(&quot; &quot;).first.to_i
+  languages     = {}
+  formats       = {}
+  countries     = {}
+  user_agents   = {}
+  content_types = {}
+  hits = 0
+  cache_hit_count = 0
+  spider_cache_hits = 0
+  home_page_views = 0
+  redirects = 0
+  
+  fastest_hit = 1000000000000000000000000
+  slowest_hit = 0
+  total_hit_time = 0.0
+  all_times = []
 
   begin
-   `cat #{file} | grep ReqLogger`.split(&quot;\n&quot;).each do |line|
+   `cat #{file} | grep ~~~~`.split(&quot;\n&quot;).each do |line|
       begin 
-        format = line.split(&quot;|&quot;)[2].strip
-        language = line.scan(/\((..)\)/).first.first
+        yaml = line.split(&quot;~~~~&quot;)[1].gsub(&quot;\\n&quot;, &quot;\n&quot;)
+        d = YAML.load(yaml)
+        
+        hits += 1
+        
+        
+        ## RATIOS
+        
+        if d[:cache_hit]
+          cache_hit_count += 1
+        end
+        
+        if d[:wikipedia_cache_hit]
+          spider_cache_hits += 1
+        end
+        
+        # Counters
+        
+        if d[:was_home_page]
+          home_page_views += 1
+        end
+        
+        if d[:was_redirected]
+          redirects += 1
+        end
+        
+        
+        ## VARIOUS HIT COUNTERS
+        
+        format = d[:format_name].to_s
+        language = d[:language_code]
+        country = d[:country_code]
+        user_agent = d[:user_agent]
+        content_type = d[:content_type]
   
         formats[format] ||= 0
         formats[format] += 1
+        
+        countries[country] ||= 0
+        countries[country] += 1
   
         languages[language] ||= 0
         languages[language] += 1
+        
+        user_agents[user_agent] ||= 0
+        user_agents[user_agent] += 1
+        
+        content_types[content_type] ||= 0
+        content_types[content_type] += 1
+        
+        # Action Speed
+        
+        time = d[:action_time]
+        total_hit_time += time
+        all_times &lt;&lt; time
+        if time &lt; fastest_hit
+          fastest_hit = time
+        end
+        if time &gt; slowest_hit
+          slowest_hit = time
+        end
       rescue
         puts &quot;problem with line&quot;
       end
    end
   rescue
-	  puts &quot;problem with line #{line}&quot;
-  end
-
-  stats.language_hits = languages
-  stats.format_hits = formats
-  stats.hits = hits
-
-  ## =======================  LOCAL CACHE HIT RATIO  =================================
-
-  cache_hit_count = 0
-  cache_miss_count = 0
-  
-  `cat #{file} | grep CACHE`.split(&quot;\n&quot;).each do |line|
-    if line.include?(&quot;HIT&quot;)
-      cache_hit_count += 1
-    elsif line.include?(&quot;MISS&quot;)
-      cache_miss_count += 1
-    end
-  end
-
-  stats.cache_hit_ratio = cache_hit_count.to_f / (cache_hit_count + cache_miss_count)
-  
-  ## =======================  WIKIPEDIA CACHE HIT RATIO  =================================
-
-  cache_hit_count = 0
-  cache_miss_count = 0
-
-  `cat #{file} | grep Spider`.split(&quot;\n&quot;).each do |line|
-    if line.include?(&quot;HIT&quot;)
-      cache_hit_count += 1
-    elsif line.include?(&quot;MISS&quot;)
-      cache_miss_count += 1
-    end
+    puts &quot;problem with line #{line}&quot;
   end
 
-  stats.spider_cache_hit_ratio = cache_hit_count.to_f / (cache_hit_count + cache_miss_count)
+  stat.language_hits = languages
+  stat.format_hits = formats
+  stat.country_hits = countries
+  stat.user_agent_hits = user_agents
+  stat.content_type_hits = content_types
+  stat.hits = hits
+  stat.cache_hit_ratio = cache_hit_count.to_f / hits
+  stat.spider_cache_hit_ratio = spider_cache_hits.to_f / hits
+  stat.redirects = redirects
+  stat.home_page_views = home_page_views
+
+  stat.slowest_action_time = slowest_hit
+  stat.fastest_action_time = fastest_hit
+  stat.average_action_time = (total_hit_time / stat.hits)
+  stat.median_action_time  = all_times.sort[(all_times.size / 2)]
   
-  ## =========================== REDIRECTS ====================================
-  
-  stats.redirects = `cat #{file} | grep Params | grep wasRedirected`.split(&quot;\n&quot;).size
-  
-  ## ======================== HOME PAGE VIEWS =================================
-  
-  stats.home_page_views = `cat #{file} | grep Params | grep \&quot;home\&quot;`.split(&quot;\n&quot;).size
-  
-  ## ============================= ERRORS ======================================
-  
-  stats.error_count = `cat #{file} | grep &quot;/usr/bin/thin&quot; | grep main`.split(&quot;\n&quot;).size
-
-  ## ========================== ACTION SPEED ==================================
-
-  fastest_hit = 1000000000000000000000000
-  slowest_hit = 0
-  total_hit_time = 0.0
-  all_times = []
+  stat.cache_size = ((`ps -eO rss | grep memcache`.split(&quot;\n&quot;).select {|a| a.include?(&quot;11211&quot;) }).first.split(&quot; &quot;)[1].to_i / 1024)
+  stat.load_average = `uptime`.scan(/[0-9.]+$/).first.to_f
 
-  `cat #{file} | grep action_time`.split(&quot;\n&quot;).each do |line|
-    begin 
-      time = line.scan(/:action_time=&gt;([0-9.]+)/).first.first.to_f
-      total_hit_time += time
-      all_times &lt;&lt; time
-      if time &lt; fastest_hit
-        fastest_hit = time
-      end
-      if time &gt; slowest_hit
-        slowest_hit = time
-      end
-    rescue NoMethodError
-      puts &quot;problem with line #{line}&quot;
-    end
+  if stat.save
+    `rm #{file}`
+  else
+    puts &quot;problem with #{stat.inspect}&quot;
   end
-
-  stats.slowest_action_time = slowest_hit
-  stats.fastest_action_time = fastest_hit
-  stats.average_action_time = (total_hit_time / stats.hits)
-  stats.median_action_time  = all_times.sort[(all_times.size / 2)]
-
-  ## ======================= CACHE SIZE ================================
-  stats.cache_size = ((`ps -eO rss | grep memcache`.split(&quot;\n&quot;).select {|a| a.include?(&quot;11211&quot;) }).first.split(&quot; &quot;)[1].to_i / 1024)
-  
-  ## ======================= SERVER LOAD ================================
-  stats.load_average = `uptime`.scan(/[0-9.]+$/).first.to_f
-
-  puts stats.save.to_s + &quot; &quot; + Time.now.to_s
-
-  `rm #{file}`
 end
 
 run_parser(ARGV[0])</diff>
      <filename>stats/parse.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,6 +2,6 @@ trap(&quot;USR1&quot;) do
 end
 
 loop do
-  `ruby parse.rb #{ARGV[0]} &amp;` 
+  `ruby /srv/mobile/current/stats/parse.rb #{ARGV[0]} &amp;` 
   sleep(60)
 end</diff>
      <filename>stats/run.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>eaecba1bf89dca11d60e662a76f429f104cc6fed</id>
    </parent>
  </parents>
  <author>
    <name>Hampton Catlin</name>
    <email>hcatlin@gmail.com</email>
  </author>
  <url>http://github.com/hcatlin/wikimedia-mobile/commit/7e41da874c13356b8845887061e753b0e75f3e92</url>
  <id>7e41da874c13356b8845887061e753b0e75f3e92</id>
  <committed-date>2009-10-27T06:45:15-07:00</committed-date>
  <authored-date>2009-10-27T06:45:15-07:00</authored-date>
  <message>more changes to the logging system</message>
  <tree>ab1be9c052a727606b8fcbd2cc730eb19f64e610</tree>
  <committer>
    <name>Hampton Catlin</name>
    <email>hcatlin@gmail.com</email>
  </committer>
</commit>
