annotate src/error_log.js.luan @ 6:d59ae3e468f1

login work
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 23 Oct 2023 21:09:05 -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