Mercurial > prosody-modules
comparison mod_log_json/mod_log_json.lua @ 5928:0b347a7c5b5f
mod_log_json: Support for logging to stdout
Hacky, but should work.
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Thu, 11 Jul 2024 10:15:21 +0100 |
| parents | 807007913f67 |
| children |
comparison
equal
deleted
inserted
replaced
| 5927:07f32bf41303 | 5928:0b347a7c5b5f |
|---|---|
| 7 module:set_global(); | 7 module:set_global(); |
| 8 | 8 |
| 9 local function sink_maker(config) | 9 local function sink_maker(config) |
| 10 local send = function () end | 10 local send = function () end |
| 11 if config.filename then | 11 if config.filename then |
| 12 local logfile = io.open(config.filename, "a+"); | 12 local logfile; |
| 13 if config.filename == "/dev/stdout" then | |
| 14 logfile = io.stdout; | |
| 15 else | |
| 16 logfile = io.open(config.filename, "a+"); | |
| 17 end | |
| 13 logfile:setvbuf("no"); | 18 logfile:setvbuf("no"); |
| 14 function send(payload) | 19 function send(payload) |
| 15 logfile:write(payload, "\n"); | 20 logfile:write(payload, "\n"); |
| 16 end | 21 end |
| 17 elseif config.udp_host and config.udp_port then | 22 elseif config.udp_host and config.udp_port then |
