You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2017/08/16 10:11:40 UTC

[whimsy] branch master updated: Save the log file for failures

This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new 4ff6833  Save the log file for failures
4ff6833 is described below

commit 4ff68338a3b8ad8e18f1dcbe61bef275b37e640e
Author: Sebb <se...@apache.org>
AuthorDate: Wed Aug 16 11:11:37 2017 +0100

    Save the log file for failures
---
 www/status/monitors/site_scan.rb | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/www/status/monitors/site_scan.rb b/www/status/monitors/site_scan.rb
index bef9dea..470fee2 100644
--- a/www/status/monitors/site_scan.rb
+++ b/www/status/monitors/site_scan.rb
@@ -6,7 +6,7 @@
 The code checks the site-scan log file
 
 Possible status level responses:
-Danger - log contains an unexpected content
+Danger - log contains unexpected content
 Warning - log hasn't been updated within a day
 Info - log is recent and contains only expected content
 
@@ -15,7 +15,8 @@ Info - log is recent and contains only expected content
 require 'time'
 
 def Monitor.site_scan(previous_status)
-  logfile = File.expand_path('../../www/logs/site-scan')
+  logdir = File.expand_path('../../www/logs')
+  logfile = File.join(logdir, 'site-scan')
   log = File.read(logfile)
 
   log.gsub! /^([-\w]+ )*https?:\S+ \w+\n/, ''
@@ -23,6 +24,12 @@ def Monitor.site_scan(previous_status)
   danger_period = 86_400 # one day
 
   if not log.empty?
+    # Archive the log file
+    require 'fileutils'
+    archive = File.join(logdir,'archive')
+    FileUtils.mkdir(archive) unless File.directory?(archive)
+    file = File.basename(logfile)
+    FileUtils.copy logfile, File.join(archive, file + '.danger'), preserve: true
     {
       level: 'danger',
       data: log.split("\n"),

-- 
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <co...@whimsical.apache.org>'].