From: Jan Kaluža Date: Tue, 24 Sep 2013 11:03:55 +0000 (+0000) Subject: Add AP_ERRORLOG_PROVIDER_ADD_EOL_STR flag for ap_errorlog_provider, bump MMN. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fce32822d9a0b899657622415ed261a8bbc50875;p=thirdparty%2Fapache%2Fhttpd.git Add AP_ERRORLOG_PROVIDER_ADD_EOL_STR flag for ap_errorlog_provider, bump MMN. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1525845 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/include/ap_mmn.h b/include/ap_mmn.h index fb5836c75d4..a7f5fa5c32a 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -439,12 +439,13 @@ * 20130702.2 (2.5.0-dev) Add ap_log_data(), ap_log_rdata(), etc. * 20130702.3 (2.5.0-dev) Add util_fcgi.h, FastCGI protocol support * 20130903.0 (2.5.0-dev) Changes sizeof(worker_score) in scoreboard + * 20130924.0 (2.5.0-dev) Add ap_errorlog_provider */ #define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */ #ifndef MODULE_MAGIC_NUMBER_MAJOR -#define MODULE_MAGIC_NUMBER_MAJOR 20130903 +#define MODULE_MAGIC_NUMBER_MAJOR 20130924 #endif #define MODULE_MAGIC_NUMBER_MINOR 0 /* 0...n */ diff --git a/include/http_core.h b/include/http_core.h index a31aa054a17..59b584853cc 100644 --- a/include/http_core.h +++ b/include/http_core.h @@ -846,6 +846,9 @@ typedef struct ap_errorlog_info { #define AP_ERRORLOG_PROVIDER_VERSION "0" #define AP_ERRORLOG_DEFAULT_PROVIDER "file" +/** add APR_EOL_STR to the end of log message */ +#define AP_ERRORLOG_PROVIDER_ADD_EOL_STR 1 + typedef struct ap_errorlog_provider ap_errorlog_provider; struct ap_errorlog_provider { @@ -863,7 +866,10 @@ struct ap_errorlog_provider { * @param len Length of the error message */ apr_status_t (*writer)(const ap_errorlog_info *info, void *handle, - const char *errstr, int len); + const char *errstr, apr_size_t len); + + /** a combination of the AP_ERRORLOG_PROVIDER_* flags */ + unsigned int flags; }; /** diff --git a/modules/loggers/mod_syslog.c b/modules/loggers/mod_syslog.c index 0c9320525fc..e04e2d92843 100644 --- a/modules/loggers/mod_syslog.c +++ b/modules/loggers/mod_syslog.c @@ -126,7 +126,8 @@ static void *syslog_error_log_init(apr_pool_t *p, server_rec *s) } static apr_status_t syslog_error_log(const ap_errorlog_info *info, - void *handle, const char *errstr, int len) + void *handle, const char *errstr, + apr_size_t len) { int level = info->level; @@ -141,7 +142,8 @@ static void syslog_register_hooks(apr_pool_t *p) { static const ap_errorlog_provider syslog_provider = { &syslog_error_log_init, - &syslog_error_log + &syslog_error_log, + 0 }; ap_register_provider(p, AP_ERRORLOG_PROVIDER_GROUP, "syslog", diff --git a/server/log.c b/server/log.c index bd40a591e38..b3157369f55 100644 --- a/server/log.c +++ b/server/log.c @@ -994,11 +994,6 @@ static void write_logline(char *errstr, apr_size_t len, apr_file_t *logf, int level) { - /* Truncate for the terminator (as apr_snprintf does) */ - if (len > MAX_STRING_LEN - sizeof(APR_EOL_STR)) { - len = MAX_STRING_LEN - sizeof(APR_EOL_STR); - } - strcpy(errstr + len, APR_EOL_STR); apr_file_puts(errstr, logf); apr_file_flush(logf); } @@ -1173,6 +1168,15 @@ static void log_error_core(const char *file, int line, int module_index, continue; } + if (logf || (s->errorlog_provider->flags & + AP_ERRORLOG_PROVIDER_ADD_EOL_STR)) { + /* Truncate for the terminator (as apr_snprintf does) */ + if (len > MAX_STRING_LEN - sizeof(APR_EOL_STR)) { + len = MAX_STRING_LEN - sizeof(APR_EOL_STR); + } + strcpy(errstr + len, APR_EOL_STR); + } + if (logf) { write_logline(errstr, len, logf, level_and_mask); }