annotate mod_log_rate/mod_log_rate.lua @ 2163:88fec2b2bd58

mod_http_logging: Fix endless loop on 0.9.x (Thanks Mint)
author Kim Alvefur <zash@zash.se>
date Sat, 16 Apr 2016 20:21:13 +0200
parents e6c7fe1be6cd
children 217456783219
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1762
e6c7fe1be6cd mod_log_rate: Log sink that reports the rate of log messages to statsmanager
Kim Alvefur <zash@zash.se>
parents:
diff changeset
1 module:set_global();
e6c7fe1be6cd mod_log_rate: Log sink that reports the rate of log messages to statsmanager
Kim Alvefur <zash@zash.se>
parents:
diff changeset
2
e6c7fe1be6cd mod_log_rate: Log sink that reports the rate of log messages to statsmanager
Kim Alvefur <zash@zash.se>
parents:
diff changeset
3 local measure = require"core.statsmanager".measure;
e6c7fe1be6cd mod_log_rate: Log sink that reports the rate of log messages to statsmanager
Kim Alvefur <zash@zash.se>
parents:
diff changeset
4
e6c7fe1be6cd mod_log_rate: Log sink that reports the rate of log messages to statsmanager
Kim Alvefur <zash@zash.se>
parents:
diff changeset
5 local function sink_maker(config)
e6c7fe1be6cd mod_log_rate: Log sink that reports the rate of log messages to statsmanager
Kim Alvefur <zash@zash.se>
parents:
diff changeset
6 local levels = {
e6c7fe1be6cd mod_log_rate: Log sink that reports the rate of log messages to statsmanager
Kim Alvefur <zash@zash.se>
parents:
diff changeset
7 debug = measure("rate", "log.debug");
e6c7fe1be6cd mod_log_rate: Log sink that reports the rate of log messages to statsmanager
Kim Alvefur <zash@zash.se>
parents:
diff changeset
8 info = measure("rate", "log.info");
e6c7fe1be6cd mod_log_rate: Log sink that reports the rate of log messages to statsmanager
Kim Alvefur <zash@zash.se>
parents:
diff changeset
9 warn = measure("rate", "log.warn");
e6c7fe1be6cd mod_log_rate: Log sink that reports the rate of log messages to statsmanager
Kim Alvefur <zash@zash.se>
parents:
diff changeset
10 error = measure("rate", "log.error");
e6c7fe1be6cd mod_log_rate: Log sink that reports the rate of log messages to statsmanager
Kim Alvefur <zash@zash.se>
parents:
diff changeset
11 };
e6c7fe1be6cd mod_log_rate: Log sink that reports the rate of log messages to statsmanager
Kim Alvefur <zash@zash.se>
parents:
diff changeset
12 return function (_, level)
e6c7fe1be6cd mod_log_rate: Log sink that reports the rate of log messages to statsmanager
Kim Alvefur <zash@zash.se>
parents:
diff changeset
13 return levels[level]();
e6c7fe1be6cd mod_log_rate: Log sink that reports the rate of log messages to statsmanager
Kim Alvefur <zash@zash.se>
parents:
diff changeset
14 end
e6c7fe1be6cd mod_log_rate: Log sink that reports the rate of log messages to statsmanager
Kim Alvefur <zash@zash.se>
parents:
diff changeset
15 end
e6c7fe1be6cd mod_log_rate: Log sink that reports the rate of log messages to statsmanager
Kim Alvefur <zash@zash.se>
parents:
diff changeset
16
e6c7fe1be6cd mod_log_rate: Log sink that reports the rate of log messages to statsmanager
Kim Alvefur <zash@zash.se>
parents:
diff changeset
17 require"core.loggingmanager".register_sink_type("measure", sink_maker);