Mercurial > prosody-modules
changeset 1762:e6c7fe1be6cd
mod_log_rate: Log sink that reports the rate of log messages to statsmanager
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 27 May 2015 13:31:33 +0200 (2015-05-27) |
parents | 6f34e51a23f0 |
children | cf3ee2eca46d |
files | mod_log_rate/mod_log_rate.lua |
diffstat | 1 files changed, 17 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_log_rate/mod_log_rate.lua Wed May 27 13:31:33 2015 +0200 @@ -0,0 +1,17 @@ +module:set_global(); + +local measure = require"core.statsmanager".measure; + +local function sink_maker(config) + local levels = { + debug = measure("rate", "log.debug"); + info = measure("rate", "log.info"); + warn = measure("rate", "log.warn"); + error = measure("rate", "log.error"); + }; + return function (_, level) + return levels[level](); + end +end + +require"core.loggingmanager".register_sink_type("measure", sink_maker);