annotate src/error_log.js.luan @ 11:62dd23f0b549

start add server
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 29 Oct 2023 22:39:31 -0600
parents 8896ffd7b152
children 3e2cb946d511
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
8896ffd7b152 start login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 local Luan = require "luan:Luan.luan"
8896ffd7b152 start login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 local error = Luan.error
8896ffd7b152 start login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 local Http = require "luan:http/Http.luan"
8896ffd7b152 start login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 local Logging = require "luan:logging/Logging.luan"
8896ffd7b152 start login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 local logger = Logging.logger "error_log.js"
8896ffd7b152 start login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6
8896ffd7b152 start login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7
8896ffd7b152 start login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 local function priority(err)
8896ffd7b152 start login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 return "error"
8896ffd7b152 start login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 end
8896ffd7b152 start login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11
8896ffd7b152 start login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 return function()
8896ffd7b152 start login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 local err = Http.request.parameters.err
8896ffd7b152 start login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 if err == nil then
8896ffd7b152 start login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 return -- stupid bots
8896ffd7b152 start login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 end
8896ffd7b152 start login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 local call = priority(err)
8896ffd7b152 start login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 logger[call](trim(err).."\n"..trim(Http.request.raw_head).."\n")
8896ffd7b152 start login
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 end