Search
j0ke.net Open Build Service
>
Projects
>
home:jg
:
projects
:
webservers
>
nginx
> nginx-syslog.patch
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File nginx-syslog.patch of Package nginx
diff -ruN nginx-0.8.4_orig/auto/make nginx-0.8.4_syslog/auto/make --- nginx-0.8.4_orig/auto/make 2009-05-12 20:15:43.000000000 +0700 +++ nginx-0.8.4_syslog/auto/make 2009-07-08 16:32:06.000000000 +0700 @@ -15,6 +15,10 @@ ngx_objs_dir=$NGX_OBJS$ngx_regex_dirsep ngx_use_pch=`echo $NGX_USE_PCH | sed -e "s/\//$ngx_regex_dirsep/g"` +#SYSLOG +if [[ "${USE_SYSLOG}" == "YES" ]]; then + CFLAGS="$CFLAGS -DUSE_SYSLOG" +fi cat << END > $NGX_MAKEFILE diff -ruN nginx-0.8.4_orig/auto/options nginx-0.8.4_syslog/auto/options --- nginx-0.8.4_orig/auto/options 2009-05-18 23:50:32.000000000 +0700 +++ nginx-0.8.4_syslog/auto/options 2009-07-08 17:57:57.000000000 +0700 @@ -110,6 +110,8 @@ MD5_OPT= MD5_ASM=NO +USE_SYSLOG=NO + USE_SHA1=NO SHA1=NONE SHA1_OPT= @@ -252,6 +254,8 @@ --with-md5-opt=*) MD5_OPT="$value" ;; --with-md5-asm) MD5_ASM=YES ;; + --with-syslog) USE_SYSLOG=YES ;; + --with-sha1=*) SHA1="$value" ;; --with-sha1-opt=*) SHA1_OPT="$value" ;; --with-sha1-asm) SHA1_ASM=YES ;; @@ -381,6 +385,8 @@ --with-md5-opt=OPTIONS set additional options for md5 building --with-md5-asm use md5 assembler sources + --with-syslog use syslog instead of files to log messages + --with-sha1=DIR set path to sha1 library sources --with-sha1-opt=OPTIONS set additional options for sha1 building --with-sha1-asm use sha1 assembler sources @@ -395,6 +401,7 @@ --with-openssl-opt=OPTIONS set additional options for OpenSSL building --with-debug enable the debugging logging + END diff -ruN nginx-0.8.4_orig/auto/summary nginx-0.8.4_syslog/auto/summary --- nginx-0.8.4_orig/auto/summary 2009-05-26 21:28:49.000000000 +0700 +++ nginx-0.8.4_syslog/auto/summary 2009-07-08 16:35:19.000000000 +0700 @@ -71,6 +71,11 @@ *) echo " + using zlib library: $ZLIB" ;; esac +case $USE_SYSLOG in + YES) echo " + using syslog" ;; + *) echo " + syslog is not used" ;; +esac + echo diff -ruN nginx-0.8.4_orig/src/core/nginx.c nginx-0.8.4_syslog/src/core/nginx.c --- nginx-0.8.4_orig/src/core/nginx.c 2009-06-06 19:41:31.000000000 +0700 +++ nginx-0.8.4_syslog/src/core/nginx.c 2009-07-08 16:39:57.000000000 +0700 @@ -8,6 +8,9 @@ #include <ngx_core.h> #include <nginx.h> +#ifdef USE_SYSLOG +#include <syslog.h> +#endif static ngx_int_t ngx_add_inherited_sockets(ngx_cycle_t *cycle); static ngx_int_t ngx_get_options(int argc, char *const *argv); @@ -271,6 +274,11 @@ ngx_ssl_init(log); #endif + /* SYSLOG SUPPORT */ +#ifdef USE_SYSLOG + openlog("nginx", LOG_ODELAY, LOG_DAEMON); +#endif + /* * init_cycle->log is required for signal handlers and * ngx_process_options() @@ -382,6 +390,10 @@ ngx_master_process_cycle(cycle); } +#ifdef USE_SYSLOG + closelog(); +#endif + return 0; } diff -ruN nginx-0.8.4_orig/src/core/ngx_conf_file.c nginx-0.8.4_syslog/src/core/ngx_conf_file.c --- nginx-0.8.4_orig/src/core/ngx_conf_file.c 2009-06-02 21:00:01.000000000 +0700 +++ nginx-0.8.4_syslog/src/core/ngx_conf_file.c 2009-07-08 19:25:57.000000000 +0700 @@ -907,6 +907,12 @@ full.data = NULL; #endif +#ifdef USE_SYSLOG + if (name->len) { + name->len = 0; + } +#endif + if (name->len) { full = *name; diff -ruN nginx-0.8.4_orig/src/core/ngx_log.c nginx-0.8.4_syslog/src/core/ngx_log.c --- nginx-0.8.4_orig/src/core/ngx_log.c 2009-04-30 20:53:42.000000000 +0700 +++ nginx-0.8.4_syslog/src/core/ngx_log.c 2009-07-08 19:26:02.000000000 +0700 @@ -7,6 +7,9 @@ #include <ngx_config.h> #include <ngx_core.h> +#ifdef USE_SYSLOG +#include <syslog.h> +#endif static char *ngx_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); @@ -90,9 +93,11 @@ u_char *p, *last, *msg; u_char errstr[NGX_MAX_ERROR_STR]; +#ifndef USE_SYSLOG if (log->file->fd == NGX_INVALID_FILE) { return; } +#endif last = errstr + NGX_MAX_ERROR_STR; @@ -139,7 +144,21 @@ ngx_linefeed(p); +#ifdef USE_SYSLOG + /* allocate a string which can hold the error message */ + char *syslogstr; + + if ((syslogstr = calloc((p - errstr + 1), sizeof(char))) != NULL) { + strncpy(syslogstr, errstr, p - errstr); + + /* write to syslog */ + syslog(LOG_CRIT, "%s", syslogstr); + + free(syslogstr); + } +#else (void) ngx_write_fd(log->file->fd, errstr, p - errstr); +#endif if (!ngx_use_stderr || level > NGX_LOG_WARN @@ -428,9 +447,13 @@ value = cf->args->elts; +#ifdef USE_SYSLOG + value[1].data = "stderr"; +#endif + if (ngx_strcmp(value[1].data, "stderr") == 0) { name.len = 0; - name.data = NULL; + name.data = ""; } else { name = value[1]; diff -ruN nginx-0.8.4_orig/src/http/modules/ngx_http_log_module.c nginx-0.8.4_syslog/src/http/modules/ngx_http_log_module.c --- nginx-0.8.4_orig/src/http/modules/ngx_http_log_module.c 2009-06-02 23:09:44.000000000 +0700 +++ nginx-0.8.4_syslog/src/http/modules/ngx_http_log_module.c 2009-07-08 19:56:29.000000000 +0700 @@ -8,6 +8,9 @@ #include <ngx_core.h> #include <ngx_http.h> +#ifdef USE_SYSLOG +#include <syslog.h> +#endif typedef struct ngx_http_log_op_s ngx_http_log_op_t; @@ -310,6 +313,19 @@ ngx_http_log_write(ngx_http_request_t *r, ngx_http_log_t *log, u_char *buf, size_t len) { +#ifdef USE_SYSLOG + /* allocate a string which can hold the error message */ + char *syslogstr; + + if ((syslogstr = calloc((len + 1), sizeof(char))) != NULL) { + strncpy(syslogstr, buf, len); + + /* write to syslog */ + syslog(LOG_NOTICE, "%s", syslogstr); + + free(syslogstr); + } +#else u_char *name; time_t now; ssize_t n; @@ -354,6 +370,7 @@ log->error_log_time = now; } +#endif } @@ -800,7 +817,11 @@ return NGX_CONF_ERROR; } +#ifdef USE_SYSLOG + ngx_http_access_log.data = ""; +#endif log->file = ngx_conf_open_file(cf->cycle, &ngx_http_access_log); + if (log->file == NULL) { return NGX_CONF_ERROR; } @@ -859,7 +880,11 @@ n = ngx_http_script_variables_count(&value[1]); if (n == 0) { +#ifdef USE_SYSLOG + value[1].data = ""; +#endif log->file = ngx_conf_open_file(cf->cycle, &value[1]); + if (log->file == NULL) { return NGX_CONF_ERROR; }