whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sam Ruby <ru...@apache.org>
Subject [whimsy.git] [1/1] Commit 8353413: copy logs when something notable happens
Date Fri, 19 Feb 2016 15:38:16 GMT
Commit 83534133ec66be5665d14a26adae55712e4e630a:
    copy logs when something notable happens


Branch: refs/heads/copy_json_logs
Author: Sam Ruby <rubys@intertwingly.net>
Committer: Sam Ruby <rubys@intertwingly.net>
Pusher: rubys <rubys@apache.org>

------------------------------------------------------------
www/status/monitors/public_json.rb                           | ++++++++++ ---
------------------------------------------------------------
13 changes: 10 additions, 3 deletions.
------------------------------------------------------------


diff --git a/www/status/monitors/public_json.rb b/www/status/monitors/public_json.rb
index f25c7c0..557e1f8 100644
--- a/www/status/monitors/public_json.rb
+++ b/www/status/monitors/public_json.rb
@@ -2,19 +2,21 @@
 # Monitor status of public json directory
 #
 
+require 'fileutils'
+
 def Monitor.public_json(previous_status)
   danger_period = 86_400 # one day
 
   warning_period = 5400 # 1.5 hours
 
-  logs = File.expand_path('../../www/logs/public-*')
+  logs = File.expand_path('../../www/logs/public-*.log')
 
   status = {}
 
   Dir[logs].each do |log|
-    begin
-      name = File.basename(log).sub('public-', '')
+    name = File.basename(log).sub('public-', '')
 
+    begin
       status[name] = {
         href: "../logs/#{File.basename(log)}",
         mtime: File.mtime(log)
@@ -69,6 +71,11 @@ def Monitor.public_json(previous_status)
         }
       }
     end
+
+    if status[name][:level]
+      FileUtils.copy log, log.sub /\.log$/, '.' + status[name][:level],
+        preserve: true
+    end
   end
 
   {data: status}

Mime
View raw message