comparison mod_log_http/mod_log_http.lua @ 4317:456b9f608fcf

mod_log_http: Switch to line buffering (thanks Zash+Ge0rG)
author Matthew Wild <mwild1@gmail.com>
date Tue, 05 Jan 2021 13:49:50 +0000
parents 3f44abfe7264
children 3bd725430f40
comparison
equal deleted inserted replaced
4316:4bba01ce2f98 4317:456b9f608fcf
1 module:set_global(); 1 Addmodule:set_global();
2 2
3 local http = require "net.http"; 3 local http = require "net.http";
4 local codes = require "net.http.codes"; 4 local codes = require "net.http.codes";
5 local json = require "util.json"; 5 local json = require "util.json";
6 6
7 local log = assert(io.open(assert(module:get_option_string("log_http_file"), "Please supply log_http_file in the config"), "a+")); 7 local log = assert(io.open(assert(module:get_option_string("log_http_file"), "Please supply log_http_file in the config"), "a+"));
8 log:setvbuf("line");
8 9
9 local function append_request(id, req) 10 local function append_request(id, req)
10 local headers = {}; 11 local headers = {};
11 for k, v in pairs(req.headers) do 12 for k, v in pairs(req.headers) do
12 table.insert(headers, { name = k, value = v }); 13 table.insert(headers, { name = k, value = v });