From 6ea4278a512bc9f1f816844222e65a4ea670db8e Mon Sep 17 00:00:00 2001 From: jvoisin Date: Fri, 24 Oct 2025 23:50:18 +0200 Subject: feat(log): add the possibility to log to a file --- src/sp_config_keywords.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/sp_config_keywords.c') 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) { } SP_PARSEKW_FN(parse_log_media) { + sp_config_log *cfg = (sp_config_log*)retval; + cfg->path = NULL; + SP_PARSE_ARG(value); - + if (!strcmp(ZSTR_VAL(value), "php")) { - *(char*)retval = SP_LOG_ZEND; + cfg->type = SP_LOG_ZEND; zend_string_release_ex(value, 1); - return SP_PARSER_SUCCESS; + return SP_PARSER_STOP; } else if (!strcmp(ZSTR_VAL(value), "syslog")) { - *(char*)retval = SP_LOG_SYSLOG; + cfg->type = SP_LOG_SYSLOG; + zend_string_release_ex(value, 1); + return SP_PARSER_STOP; + } else if (!strncmp(ZSTR_VAL(value), "file:", strlen("file:"))) { + cfg->type = SP_LOG_FILE; + cfg->path = strdup(ZSTR_VAL(value)+strlen("file:")); zend_string_release_ex(value, 1); - return SP_PARSER_SUCCESS; + return SP_PARSER_STOP; } - sp_log_err("config", "." SP_TOKEN_LOG_MEDIA "() only supports 'syslog' or 'php' on line %zu", kw->lineno); + 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)); return SP_PARSER_ERROR; } -- cgit v1.3