diff options
Diffstat (limited to 'src/sp_utils.c')
| -rw-r--r-- | src/sp_utils.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/sp_utils.c b/src/sp_utils.c index 775ff95..41eb638 100644 --- a/src/sp_utils.c +++ b/src/sp_utils.c | |||
| @@ -43,7 +43,7 @@ void sp_log_msgf(char const* const restrict feature, int level, int type, | |||
| 43 | break; | 43 | break; |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | switch (SPCFG(log_media)) { | 46 | switch (SPCFG(log_media).type) { |
| 47 | case SP_LOG_SYSLOG: { | 47 | case SP_LOG_SYSLOG: { |
| 48 | const char* error_filename = zend_get_executed_filename(); | 48 | const char* error_filename = zend_get_executed_filename(); |
| 49 | int syslog_level = (level == E_ERROR) ? LOG_ERR : LOG_INFO; | 49 | int syslog_level = (level == E_ERROR) ? LOG_ERR : LOG_INFO; |
| @@ -54,6 +54,20 @@ void sp_log_msgf(char const* const restrict feature, int level, int type, | |||
| 54 | closelog(); | 54 | closelog(); |
| 55 | break; | 55 | break; |
| 56 | } | 56 | } |
| 57 | case SP_LOG_FILE: { | ||
| 58 | FILE* logf = fopen(SPCFG(log_media).path, "a"); | ||
| 59 | if (!logf) { | ||
| 60 | zend_error(level, "[snuffleupagus][%s][logging][log] unable to open %s to log", client_ip, | ||
| 61 | SPCFG(log_media).path); | ||
| 62 | } else { | ||
| 63 | int error_lineno = zend_get_executed_lineno(TSRMLS_C); | ||
| 64 | const char* error_filename = zend_get_executed_filename(); | ||
| 65 | fprintf(logf, "[snuffleupagus][%s][%s][%s] %s in %s on line %d\n", | ||
| 66 | client_ip, feature, logtype, msg, error_filename, error_lineno); | ||
| 67 | fclose(logf); | ||
| 68 | } | ||
| 69 | break; | ||
| 70 | } | ||
| 57 | case SP_LOG_ZEND: | 71 | case SP_LOG_ZEND: |
| 58 | default: | 72 | default: |
| 59 | zend_error(level, "[snuffleupagus][%s][%s][%s] %s", client_ip, feature, | 73 | zend_error(level, "[snuffleupagus][%s][%s][%s] %s", client_ip, feature, |
