Mercurial Hosting > chat
comparison src/error_log.js.luan @ 90:5240c054dcd4
logging
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 13 Mar 2025 18:58:48 -0600 |
parents | 2c63b10781e1 |
children |
comparison
equal
deleted
inserted
replaced
89:3053a4fc10be | 90:5240c054dcd4 |
---|---|
2 local error = Luan.error | 2 local error = Luan.error |
3 local String = require "luan:String.luan" | 3 local String = require "luan:String.luan" |
4 local trim = String.trim or error() | 4 local trim = String.trim or error() |
5 local regex = String.regex or error() | 5 local regex = String.regex or error() |
6 local contains = String.contains or error() | 6 local contains = String.contains or error() |
7 local Table = require "luan:Table.luan" | |
8 local concat = Table.concat or error() | |
7 local Http = require "luan:http/Http.luan" | 9 local Http = require "luan:http/Http.luan" |
8 local Logging = require "luan:logging/Logging.luan" | 10 local Logging = require "luan:logging/Logging.luan" |
9 local logger = Logging.logger "error_log.js" | 11 local logger = Logging.logger "error_log.js" |
10 | 12 |
11 | 13 |
14 local bad_agents = { | |
15 [[Version/14\.]] | |
16 } | |
17 local bad_agents_ptn = regex(concat(bad_agents,"|")) | |
18 | |
12 local function priority(err) | 19 local function priority(err) |
20 local agent = Http.request.headers["user-agent"] | |
21 if agent~=nil and bad_agents_ptn.matches(agent) then return "info" end | |
13 return "error" | 22 return "error" |
14 end | 23 end |
15 | 24 |
16 return function() | 25 return function() |
17 local err = Http.request.parameters.err | 26 local err = Http.request.parameters.err |