7
|
1 local Luan = require "luan:Luan.luan"
|
|
2 local error = Luan.error
|
|
3 local String = require "luan:String.luan"
|
|
4 local trim = String.trim or error()
|
|
5 local Table = require "luan:Table.luan"
|
|
6 local Http = require "luan:http/Http.luan"
|
|
7 local Logging = require "luan:logging/Logging.luan"
|
|
8 local logger = Logging.logger "error_log"
|
|
9
|
|
10 --[=[ when needed
|
|
11 local bad_bots = {
|
|
12 [[Googlebot]]
|
|
13 [[bingbot]]
|
|
14 }
|
|
15 local bad_bots_ptn = Table.concat(bad_bots,"|")
|
|
16 ]=]
|
|
17
|
|
18 local function priority(err)
|
|
19 --[=[
|
|
20 local agent = Http.request.headers["user-agent"]
|
|
21 if agent~=nil and matches(agent,bad_bots_ptn) then return "info" end
|
|
22 if matches(err,[[Uncaught TypeError: Illegal invocation]]) then return "warn" end
|
|
23 if matches(err,[[\Q?fbclid=\E]]) then return "warn" end
|
|
24 ]=]
|
|
25 return "error"
|
|
26 end
|
|
27
|
|
28 return function()
|
|
29 local err = Http.request.parameters.err
|
|
30 if err == nil then
|
|
31 return -- stupid bots
|
|
32 end
|
|
33 local call = priority(err)
|
|
34 logger[call](trim(err).."\n"..trim(Http.request.raw_head).."\n")
|
|
35 end
|