From 3f3f6dcd9be7f5bccf22a4d4a2e7c72de6a9c636 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 9 Mar 2023 21:49:23 +0000 Subject: [PATCH] Improve error handling in API statistics daemon --- cookbooks/web/templates/default/api-statistics.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cookbooks/web/templates/default/api-statistics.erb b/cookbooks/web/templates/default/api-statistics.erb index 297a2ef51..ce3af0b34 100644 --- a/cookbooks/web/templates/default/api-statistics.erb +++ b/cookbooks/web/templates/default/api-statistics.erb @@ -34,7 +34,7 @@ statistics = { File::Tail::Logfile.tail("/var/log/apache2/access.log") do |line| begin - hash = parser.parse(line) + hash = parser.parse!(line) uri = categorise_uri(hash["%r"]) status = hash["%>s"] @@ -51,8 +51,8 @@ File::Tail::Logfile.tail("/var/log/apache2/access.log") do |line| statistics[:seconds][[uri, status]] += seconds statistics[:ssl][[protocol, cipher]] += 1 unless protocol == "-" statistics[:auth][auth] += 1 unless auth == "-" - rescue ApacheLogRegex::ParseError - # nil + rescue ApacheLogRegex::ParseError => ex + STDERR.puts ex.to_s end if Time.now - last_write > 10 -- 2.39.5