Mercurial Hosting > chat
view src/error_log.js.luan @ 93:d0566cc4a2ac default tip
uploa fix
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 03 Apr 2025 19:47:48 -0600 |
parents | 5240c054dcd4 |
children |
line wrap: on
line source
local Luan = require "luan:Luan.luan" local error = Luan.error local String = require "luan:String.luan" local trim = String.trim or error() local regex = String.regex or error() local contains = String.contains or error() local Table = require "luan:Table.luan" local concat = Table.concat or error() local Http = require "luan:http/Http.luan" local Logging = require "luan:logging/Logging.luan" local logger = Logging.logger "error_log.js" local bad_agents = { [[Version/14\.]] } local bad_agents_ptn = regex(concat(bad_agents,"|")) local function priority(err) local agent = Http.request.headers["user-agent"] if agent~=nil and bad_agents_ptn.matches(agent) then return "info" end return "error" end return function() local err = Http.request.parameters.err if err == nil then return -- stupid bots end local call = priority(err) logger[call](trim(err).."\n"..trim(Http.request.raw_head).."\n") end