diff options
| author | Thibault "bui" Koechlin | 2019-08-31 15:32:36 +0200 |
|---|---|---|
| committer | jvoisin | 2019-08-31 13:32:36 +0000 |
| commit | 504f02992ace82a5520bc0ca43d9562c077a06e4 (patch) | |
| tree | 94934cf269abe7a8dbdf0a8bdb4ddb1d51cb4f30 /src/sp_utils.c | |
| parent | f7e25b29c1cd5273675dbb3d6883c40377d8315d (diff) | |
Support direct syslog logging
Add the possibility to log directly into the syslog, instead of using php's log system.
Diffstat (limited to 'src/sp_utils.c')
| -rw-r--r-- | src/sp_utils.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/sp_utils.c b/src/sp_utils.c index 7641808..5ddf0b9 100644 --- a/src/sp_utils.c +++ b/src/sp_utils.c | |||
| @@ -15,7 +15,24 @@ 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 | zend_error(type, "[snuffleupagus][%s] %s", feature, msg); | 18 | switch (SNUFFLEUPAGUS_G(config).log_media) { |
| 19 | case SP_SYSLOG: | ||
| 20 | openlog(PHP_SNUFFLEUPAGUS_EXTNAME, LOG_PID, LOG_AUTH); | ||
| 21 | const char* error_filename = zend_get_executed_filename(); | ||
| 22 | int syslog_level = SP_LOG_DROP ? LOG_ERR : LOG_INFO; | ||
| 23 | int error_lineno = zend_get_executed_lineno(TSRMLS_C); | ||
| 24 | syslog(syslog_level, "[%s] %s in %s on line %d", feature, msg, | ||
| 25 | error_filename, error_lineno); | ||
| 26 | closelog(); | ||
| 27 | if (type == SP_LOG_DROP) { | ||
| 28 | zend_bailout(); | ||
| 29 | } | ||
| 30 | break; | ||
| 31 | case SP_ZEND: | ||
| 32 | default: | ||
| 33 | zend_error(type, "[snuffleupagus][%s] %s", feature, msg); | ||
| 34 | break; | ||
| 35 | } | ||
| 19 | } | 36 | } |
| 20 | 37 | ||
| 21 | int compute_hash(const char* const filename, char* file_hash) { | 38 | int compute_hash(const char* const filename, char* file_hash) { |
