diff options
| author | jvoisin | 2025-10-24 23:50:18 +0200 |
|---|---|---|
| committer | jvoisin | 2025-10-24 23:55:13 +0200 |
| commit | 6ea4278a512bc9f1f816844222e65a4ea670db8e (patch) | |
| tree | 8c645390d3ad5202e3a894f9f6779f4cb590b02e /src/sp_config_keywords.c | |
| parent | a167c4d23feb03e6c5b53f41724bbfcb813bf04b (diff) | |
feat(log): add the possibility to log to a filelog2file
Diffstat (limited to 'src/sp_config_keywords.c')
| -rw-r--r-- | src/sp_config_keywords.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/sp_config_keywords.c b/src/sp_config_keywords.c index a5b4c5d..7f41e38 100644 --- a/src/sp_config_keywords.c +++ b/src/sp_config_keywords.c | |||
| @@ -57,19 +57,27 @@ SP_PARSE_FN(parse_session) { | |||
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | SP_PARSEKW_FN(parse_log_media) { | 59 | SP_PARSEKW_FN(parse_log_media) { |
| 60 | sp_config_log *cfg = (sp_config_log*)retval; | ||
| 61 | cfg->path = NULL; | ||
| 62 | |||
| 60 | SP_PARSE_ARG(value); | 63 | SP_PARSE_ARG(value); |
| 61 | 64 | ||
| 62 | if (!strcmp(ZSTR_VAL(value), "php")) { | 65 | if (!strcmp(ZSTR_VAL(value), "php")) { |
| 63 | *(char*)retval = SP_LOG_ZEND; | 66 | cfg->type = SP_LOG_ZEND; |
| 64 | zend_string_release_ex(value, 1); | 67 | zend_string_release_ex(value, 1); |
| 65 | return SP_PARSER_SUCCESS; | 68 | return SP_PARSER_STOP; |
| 66 | } else if (!strcmp(ZSTR_VAL(value), "syslog")) { | 69 | } else if (!strcmp(ZSTR_VAL(value), "syslog")) { |
| 67 | *(char*)retval = SP_LOG_SYSLOG; | 70 | cfg->type = SP_LOG_SYSLOG; |
| 71 | zend_string_release_ex(value, 1); | ||
| 72 | return SP_PARSER_STOP; | ||
| 73 | } else if (!strncmp(ZSTR_VAL(value), "file:", strlen("file:"))) { | ||
| 74 | cfg->type = SP_LOG_FILE; | ||
| 75 | cfg->path = strdup(ZSTR_VAL(value)+strlen("file:")); | ||
| 68 | zend_string_release_ex(value, 1); | 76 | zend_string_release_ex(value, 1); |
| 69 | return SP_PARSER_SUCCESS; | 77 | return SP_PARSER_STOP; |
| 70 | } | 78 | } |
| 71 | 79 | ||
| 72 | sp_log_err("config", "." SP_TOKEN_LOG_MEDIA "() only supports 'syslog' or 'php' on line %zu", kw->lineno); | 80 | sp_log_err("config", "." SP_TOKEN_LOG_MEDIA "() only supports 'syslog', 'file:' or 'php' on line %zu, got '%s' instead", kw->lineno, ZSTR_VAL(value)); |
| 73 | 81 | ||
| 74 | return SP_PARSER_ERROR; | 82 | return SP_PARSER_ERROR; |
| 75 | } | 83 | } |
