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;
15 static const char *get_name(
void) {
16 return "Windows Event Log";
19 static DWORD map_priority(EXTENSION_LOG_LEVEL severity)
23 case EXTENSION_LOG_WARNING:
24 priority = EVENTLOG_ERROR_TYPE;
26 case EXTENSION_LOG_INFO:
27 priority = EVENTLOG_WARNING_TYPE;
30 priority = EVENTLOG_INFORMATION_TYPE;
36 static void logger_log(EXTENSION_LOG_LEVEL severity,
37 const void* client_cookie,
41 if (severity >= current_log_level) {
43 const char *strings[1] = {
48 int len = vsnprintf(buffer,
sizeof(buffer), fmt, ap);
52 ReportEvent(handle, map_priority(severity), 0, 0,
53 NULL, 1, 0, strings, NULL);
63 static void on_log_level(
const void *cookie, ENGINE_EVENT_TYPE
type,
64 const void *event_data,
const void *cb_data) {
66 current_log_level = sapi->log->get_level();
72 GET_SERVER_API get_server_api) {
74 sapi = get_server_api();
79 current_log_level = sapi->log->get_level();
81 if ((handle = RegisterEventSource(NULL,
"memcached")) == NULL) {
82 fprintf(stderr,
"Failed to register event source\n");