summaryrefslogtreecommitdiff
path: root/src/sp_utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sp_utils.c')
-rw-r--r--src/sp_utils.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/sp_utils.c b/src/sp_utils.c
index 5ddf0b9..0f87f17 100644
--- a/src/sp_utils.c
+++ b/src/sp_utils.c
@@ -15,13 +15,17 @@ void sp_log_msg(char const* feature, int type, const char* fmt, ...) {
15 vspprintf(&msg, 0, fmt, args); 15 vspprintf(&msg, 0, fmt, args);
16 va_end(args); 16 va_end(args);
17 17
18 const char *client_ip = getenv("REMOTE_ADDR");
19 if (!client_ip) {
20 client_ip = "0.0.0.0";
21 }
18 switch (SNUFFLEUPAGUS_G(config).log_media) { 22 switch (SNUFFLEUPAGUS_G(config).log_media) {
19 case SP_SYSLOG: 23 case SP_SYSLOG:
20 openlog(PHP_SNUFFLEUPAGUS_EXTNAME, LOG_PID, LOG_AUTH); 24 openlog(PHP_SNUFFLEUPAGUS_EXTNAME, LOG_PID, LOG_AUTH);
21 const char* error_filename = zend_get_executed_filename(); 25 const char* error_filename = zend_get_executed_filename();
22 int syslog_level = SP_LOG_DROP ? LOG_ERR : LOG_INFO; 26 int syslog_level = SP_LOG_DROP ? LOG_ERR : LOG_INFO;
23 int error_lineno = zend_get_executed_lineno(TSRMLS_C); 27 int error_lineno = zend_get_executed_lineno(TSRMLS_C);
24 syslog(syslog_level, "[%s] %s in %s on line %d", feature, msg, 28 syslog(syslog_level, "[snuffleupagus][%s][%s] %s in %s on line %d", client_ip, feature, msg,
25 error_filename, error_lineno); 29 error_filename, error_lineno);
26 closelog(); 30 closelog();
27 if (type == SP_LOG_DROP) { 31 if (type == SP_LOG_DROP) {
@@ -30,7 +34,7 @@ void sp_log_msg(char const* feature, int type, const char* fmt, ...) {
30 break; 34 break;
31 case SP_ZEND: 35 case SP_ZEND:
32 default: 36 default:
33 zend_error(type, "[snuffleupagus][%s] %s", feature, msg); 37 zend_error(type, "[snuffleupagus][%s][%s] %s", client_ip, feature, msg);
34 break; 38 break;
35 } 39 }
36} 40}