annotate src/error_log.js.luan @ 80:cb2808b8b1ad

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 10 Mar 2025 21:54:46 -0600
parents 2c63b10781e1
children 5240c054dcd4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 local Luan = require "luan:Luan.luan"
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 local error = Luan.error
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 local String = require "luan:String.luan"
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 local trim = String.trim or error()
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 local regex = String.regex or error()
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 local contains = String.contains or error()
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 local Http = require "luan:http/Http.luan"
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 local Logging = require "luan:logging/Logging.luan"
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 local logger = Logging.logger "error_log.js"
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 local function priority(err)
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 return "error"
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 end
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 return function()
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 local err = Http.request.parameters.err
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 if err == nil then
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 return -- stupid bots
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 end
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 local call = priority(err)
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 logger[call](trim(err).."\n"..trim(Http.request.raw_head).."\n")
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 end