You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by cu...@apache.org on 2018/05/07 23:24:49 UTC
[whimsy] 02/02: Add simplistic access log display
This is an automated email from the ASF dual-hosted git repository.
curcuru pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git
commit 6ca5db82135df2f93cae68e7a2b206db1d9c8166
Author: Shane Curcuru <as...@shanecurcuru.org>
AuthorDate: Mon May 7 19:24:39 2018 -0400
Add simplistic access log display
---
www/members/logs.cgi | 160 ++++++++++++++++++++++++++++++++++++---------------
1 file changed, 114 insertions(+), 46 deletions(-)
diff --git a/www/members/logs.cgi b/www/members/logs.cgi
index f7a8fa6..2bc15b4 100755
--- a/www/members/logs.cgi
+++ b/www/members/logs.cgi
@@ -7,6 +7,114 @@ require 'wunderbar'
require 'wunderbar/bootstrap'
require 'whimsy/logparser'
+# Emit table of interesting error logs
+def display_errors()
+ _whimsy_panel_table(
+ title: 'Partial error listing',
+ helpblock: -> {
+ _ 'This only includes a subset of possibly interesting error log entries.'
+ _a 'See the full server logs directory.', href: '/members/log'
+ }
+ ) do
+ logs = LogParser.get_errors()
+ _table.table.table_hover.table_striped do
+ _thead_ do
+ _tr do
+ _th 'Date/Time'
+ _th ''
+ _th 'Error text or array of errors'
+ end
+ _tbody do
+ logs.each do | key, val |
+ _tr_ do
+ _td do
+ _ key
+ end
+ _td do
+ if val.is_a?(Array)
+ _span.glyphicon.glyphicon_remove_circle :aria_hidden, aria_label: 'List of code errors'
+ elsif /Passenger/ =~ val
+ _span.glyphicon.glyphicon_briefcase :aria_hidden, aria_label: 'Passenger server message'
+ else
+ _span.glyphicon.glyphicon_remove_sign :aria_hidden, aria_label: 'stderr line from code'
+ end
+ end
+ _td do
+ if val.is_a?(Array)
+ val.each do |i|
+ _ i
+ _br
+ end
+ else
+ _ val
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+end
+
+# Emit table of interesting access logs (optional, with ?access)
+def display_access(f)
+ apps, misses = LogParser.get_access_reports(f)
+
+ _p do
+ _ 'This only includes a small subset of possibly interesting access log entries, roughly categorized by major application (board, roster, etc.)'
+ _a 'See the full server logs directory.', href: '/members/log'
+ end
+ _h2 'Access Log Synopsis - by Application'
+ apps.each do |name, data|
+ _h3 "#{name} - application"
+ _table.table.table_hover.table_striped do
+ _thead_ do
+ _tr do
+ _th 'User list'
+ _th 'URLs hit (total)'
+ end
+ _tbody do
+ _tr_ do
+ _td do
+ data['remote_user'].each do |remote_user|
+ _ remote_user
+ end
+ end
+ _td do
+ data['uri'].sort.each do |uri|
+ _ uri
+ _br
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ _whimsy_panel(title: 'Access Log Synopsis - Error URLs') do
+ _p 'This is a simplistic listing of all URLs with 4xx/5xx error codes (excluding obvious bots).'
+ erruri = {}
+ errref = {}
+ misses.each do |h|
+ erruri[h['uri']] = ''
+ errref[h['referer']] = ''
+ end
+ _h3 'URIs hit that returned 4xx/5xx errors'
+ _ul do
+ erruri.keys.sort.each do |u|
+ _li u
+ end
+ end
+ _h3 'Referrers for all above 4xx/5xx errors'
+ _ul do
+ errref.keys.sort.each do |u|
+ _li u
+ end
+ end
+ end
+end
+
_html do
_body? do
_whimsy_body(
@@ -27,52 +135,12 @@ _html do
end
}
) do
- _whimsy_panel_table(
- title: 'Partial error listing',
- helpblock: -> {
- _ 'This only includes a subset of possibly interesting error log entries.'
- _a 'See the full server logs directory.', href: '/members/log'
- }
- ) do
- logs = LogParser.get_errors()
- _table.table.table_hover.table_striped do
- _thead_ do
- _tr do
- _th 'Date/Time'
- _th ''
- _th 'Error text or array of errors'
- end
- _tbody do
- logs.each do | key, val |
- _tr_ do
- _td do
- _ key
- end
- _td do
- if val.is_a?(Array)
- _span.glyphicon.glyphicon_remove_circle :aria_hidden, aria_label: 'List of code errors'
- elsif /Passenger/ =~ val
- _span.glyphicon.glyphicon_briefcase :aria_hidden, aria_label: 'Passenger server message'
- else
- _span.glyphicon.glyphicon_remove_sign :aria_hidden, aria_label: 'stderr line from code'
- end
- end
- _td do
- if val.is_a?(Array)
- val.each do |i|
- _ i
- _br
- end
- else
- _ val
- end
- end
- end
- end
- end
- end
- end
+ # Display whimsy_access.log data if requested (takes longer)
+ if true # ENV['QUERY_STRING'].include? 'access'
+ display_access('/Users/curcuru/src/g/wdev/errors/whimsy_access.log-20180507.gz')
+ else
+ display_errors()
end
end
end
-end
+end
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
curcuru@apache.org.