1 /* 2 * Message logging for an Apache module. 3 * 4 * These functions are used for message logging callbacks inside the WebAuth 5 * context. Following the capabilities of libwebauth, four levels of error 6 * reporting are available: trace, info, notice, and warning. More severe 7 * errors are assumed to return an error from the WebAuth library and will 8 * then be logged directly by the module. 9 * 10 * These functions all do per-request logging. Logging without request 11 * information must be done separately. 12 * 13 * Written by Russ Allbery <eagle@eyrie.org> 14 * Copyright 2013 15 * The Board of Trustees of the Leland Stanford Junior University 16 * 17 * See LICENSE for licensing terms. 18 */ 19 20 #include <config-mod.h> 21 #include <portable/apache.h> 22 #include <portable/apr.h> 23 24 #include <modules/webkdc/mod_webkdc.h> 25 #include <webauth/basic.h> 26 #include <util/macros.h> 27 28 APLOG_USE_MODULE(webkdc); 29 30 /* 31 * For Apache 2.2 and earlier, we want to add the module name as a prefix to 32 * each of the messages, since there's no other way to determine where the 33 * message came from. In Apache 2.4, the module is part of the metadata, so 34 * we should omit this. 35 */ 36 #if AP_SERVER_MAJORVERSION_NUMBER > 2 \ 37 || (AP_SERVER_MAJORVERSION_NUMBER == 2 \ 38 && AP_SERVER_MINORVERSION_NUMBER >= 4) 39 # define LOG_FUNC(name, level, module) \ 40 void \ 41 name(struct webauth_context *ctx UNUSED, void *data, \ 42 const char *msg) \ 43 { \ 44 request_rec *r = data; \ 45 ap_log_rerror(APLOG_MARK, APLOG_ ## level, 0, r, "%s", msg); \ 46 } 47 #else 48 # define LOG_FUNC(name, level, module) \ 49 void \ 50 name(struct webauth_context *ctx UNUSED, void *data, \ 51 const char *message) \ 52 { \ 53 request_rec *r = data; \ 54 ap_log_rerror(APLOG_MARK, APLOG_ ## level, 0, r, \ 55 "mod_" #module ": %s", message); \ 56 } 57 #endif 58 59 LOG_FUNC(mwk_log_trace, TRACE1, webkdc) 60 LOG_FUNC(mwk_log_info, INFO, webkdc) 61 LOG_FUNC(mwk_log_notice, NOTICE, webkdc) 62 LOG_FUNC(mwk_log_warning, WARNING, webkdc) 63