function is_error_record(record)
if not record then
return false
end
local error_indicators = {
"level", "severity", "status", "type", "message", "log_level"
}
for _, indicator in ipairs(error_indicators) do
local value = record[indicator]
if value then
local str_value = tostring(value):lower()
if str_value:match("error") or
str_value:match("err") or
str_value:match("fail") or
str_value:match("exception") or
str_value:match("critical") or
str_value:match("fatal") or
str_value:match("panic") then
return true
end
end
end
local status = record["status"]
if status then
local status_num = tonumber(status)
if status_num and (status_num >= 400) then
return true
end
end
local http_status = record["http_status"]
if http_status then
local status_num = tonumber(http_status)
if status_num and (status_num >= 400) then
return true
end
end
return false
end
table.insert(record_processors, function(record)
if is_error_record(record) then
beep()
end
return {}
end)