6 #include <memcached/extension.h>
7 #include <memcached/engine.h>
8 #include "protocol_extension.h"
10 static EXTENSION_LOG_LEVEL current_log_level = EXTENSION_LOG_WARNING;
13 static const char *get_name(
void) {
17 static int map_priority(EXTENSION_LOG_LEVEL severity)
21 case EXTENSION_LOG_WARNING:
22 priority = LOG_WARNING;
24 case EXTENSION_LOG_INFO:
25 priority = LOG_NOTICE;
27 case EXTENSION_LOG_DETAIL:
30 case EXTENSION_LOG_DEBUG:
38 static void logger_log(EXTENSION_LOG_LEVEL severity,
39 const void* client_cookie,
43 if (severity >= current_log_level) {
47 int len = vsnprintf(buffer,
sizeof(buffer), fmt, ap);
51 syslog(map_priority(severity),
"%s", buffer);
61 static void on_log_level(
const void *cookie, ENGINE_EVENT_TYPE
type,
62 const void *event_data,
const void *cb_data) {
64 current_log_level = sapi->log->get_level();
65 setlogmask(LOG_UPTO(map_priority(current_log_level)));
71 GET_SERVER_API get_server_api) {
73 sapi = get_server_api();
78 current_log_level = sapi->log->get_level();
79 openlog(
"memcached", LOG_NDELAY | LOG_CONS | LOG_PID, LOG_DAEMON);
80 setlogmask(LOG_UPTO(map_priority(current_log_level)));