mirror of https://github.com/openresty/openresty
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.8 KiB
C
61 lines
1.8 KiB
C
5 years ago
|
diff --git a/src/core/ngx_cycle.h b/src/core/ngx_cycle.h
|
||
|
index c51b7ff..4c335b9 100644
|
||
|
--- a/src/core/ngx_cycle.h
|
||
|
+++ b/src/core/ngx_cycle.h
|
||
|
@@ -22,9 +22,14 @@
|
||
|
#define NGX_DEBUG_POINTS_ABORT 2
|
||
|
|
||
|
|
||
|
+#define HAVE_INTERCEPT_ERROR_LOG_PATCH
|
||
|
+
|
||
|
+
|
||
|
typedef struct ngx_shm_zone_s ngx_shm_zone_t;
|
||
|
|
||
|
typedef ngx_int_t (*ngx_shm_zone_init_pt) (ngx_shm_zone_t *zone, void *data);
|
||
|
+typedef ngx_int_t (*ngx_log_intercept_pt) (ngx_log_t *log, ngx_uint_t level,
|
||
|
+ u_char *buf, size_t len);
|
||
|
|
||
|
struct ngx_shm_zone_s {
|
||
|
void *data;
|
||
|
@@ -75,6 +80,10 @@ struct ngx_cycle_s {
|
||
|
ngx_str_t prefix;
|
||
|
ngx_str_t lock_file;
|
||
|
ngx_str_t hostname;
|
||
|
+
|
||
|
+ ngx_log_intercept_pt intercept_error_log_handler;
|
||
|
+ void *intercept_error_log_data;
|
||
|
+ unsigned entered_logger; /* :1 */
|
||
|
};
|
||
|
|
||
|
|
||
|
diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c
|
||
|
index 8e9408d..ed9b11b 100644
|
||
|
--- a/src/core/ngx_log.c
|
||
|
+++ b/src/core/ngx_log.c
|
||
|
@@ -112,6 +112,8 @@ ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
|
||
|
ngx_uint_t wrote_stderr, debug_connection;
|
||
|
u_char errstr[NGX_MAX_ERROR_STR];
|
||
|
|
||
|
+ ngx_log_intercept_pt log_intercept = NULL;
|
||
|
+
|
||
|
last = errstr + NGX_MAX_ERROR_STR;
|
||
|
|
||
|
p = ngx_cpymem(errstr, ngx_cached_err_log_time.data,
|
||
|
@@ -153,6 +155,16 @@ ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
|
||
|
p = last - NGX_LINEFEED_SIZE;
|
||
|
}
|
||
|
|
||
|
+ if (ngx_cycle) {
|
||
|
+ log_intercept = ngx_cycle->intercept_error_log_handler;
|
||
|
+ }
|
||
|
+
|
||
|
+ if (log_intercept && !ngx_cycle->entered_logger) {
|
||
|
+ ngx_cycle->entered_logger = 1;
|
||
|
+ log_intercept(log, level, errstr, p - errstr);
|
||
|
+ ngx_cycle->entered_logger = 0;
|
||
|
+ }
|
||
|
+
|
||
|
ngx_linefeed(p);
|
||
|
|
||
|
wrote_stderr = 0;
|