You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by Sam Ruby <ru...@apache.org> on 2016/02/19 16:38:16 UTC
[whimsy.git] [1/1] Commit 8353413: copy logs when something notable happens
Commit 83534133ec66be5665d14a26adae55712e4e630a:
copy logs when something notable happens
Branch: refs/heads/copy_json_logs
Author: Sam Ruby <ru...@intertwingly.net>
Committer: Sam Ruby <ru...@intertwingly.net>
Pusher: rubys <ru...@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}
Re: [whimsy.git] [1/1] Commit 8353413: copy logs when something
notable happens
Posted by sebb <se...@gmail.com>.
FTR, public_json.rb has been updated to copy non-info level files to
the archive/ subdirectory.
The level name is appended so that more failed logs are kept (without
needing to add a timestamp)
On 22 February 2016 at 11:11, sebb <se...@gmail.com> wrote:
> On 19 February 2016 at 15:38, Sam Ruby <ru...@apache.org> wrote:
>> Commit 83534133ec66be5665d14a26adae55712e4e630a:
>> copy logs when something notable happens
>>
>>
>> Branch: refs/heads/copy_json_logs
>> Author: Sam Ruby <ru...@intertwingly.net>
>> Committer: Sam Ruby <ru...@intertwingly.net>
>> Pusher: rubys <ru...@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')
>
> I don't understand the above change - AFAIK the cron jobs have not
> changed and still create log files without the .log suffix
> So won't this cause the logs to be missed?
>
>>
>> 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
>
> I think it would be better to store the files in a separate directory.
>
> Not sure it's sufficient to keep only the last of each status type.
> I had in mind to keep the copy until it was deleted, e.g. using a date.
>
>> + end
>> end
>>
>> {data: status}
Re: [whimsy.git] [1/1] Commit 8353413: copy logs when something
notable happens
Posted by sebb <se...@gmail.com>.
On 19 February 2016 at 15:38, Sam Ruby <ru...@apache.org> wrote:
> Commit 83534133ec66be5665d14a26adae55712e4e630a:
> copy logs when something notable happens
>
>
> Branch: refs/heads/copy_json_logs
> Author: Sam Ruby <ru...@intertwingly.net>
> Committer: Sam Ruby <ru...@intertwingly.net>
> Pusher: rubys <ru...@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')
I don't understand the above change - AFAIK the cron jobs have not
changed and still create log files without the .log suffix
So won't this cause the logs to be missed?
>
> 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
I think it would be better to store the files in a separate directory.
Not sure it's sufficient to keep only the last of each status type.
I had in mind to keep the copy until it was deleted, e.g. using a date.
> + end
> end
>
> {data: status}