From aa5d6895d0ac8c6ea050a8ea55e2f8a39ddfe365 Mon Sep 17 00:00:00 2001 From: xXx-caillou-xXx Date: Tue, 28 Aug 2018 14:24:29 +0200 Subject: Use php's logging functions This commit replace our usage of `php_log_err` with `zend_error`. This should allow administrators to display errors in the webpage, should they want to; and to properly manipulate the verbosity's level. This should close #217 --- src/sp_utils.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/sp_utils.h') diff --git a/src/sp_utils.h b/src/sp_utils.h index 7e1103c..62040e7 100644 --- a/src/sp_utils.h +++ b/src/sp_utils.h @@ -28,12 +28,14 @@ #define HOOK_FUNCTION_BY_REGEXP(regexp, hook_table, new_function) \ hook_regexp(regexp, SNUFFLEUPAGUS_G(hook_table), new_function) -#define SP_LOG_SIMULATION "simulation" -#define SP_LOG_DROP "drop" -#define SP_LOG_DEBUG "debug" -#define SP_LOG_ERROR "error" +#define SP_LOG_SIMULATION E_WARNING +#define SP_LOG_DROP E_ERROR +#define SP_LOG_DEBUG E_NOTICE +#define SP_LOG_ERROR E_ERROR +#define SP_LOG_WARN E_WARNING #define sp_log_err(feature, ...) sp_log_msg(feature, SP_LOG_ERROR, __VA_ARGS__) +#define sp_log_warn(feature, ...) sp_log_msg(feature, SP_LOG_WARN, __VA_ARGS__) #ifdef SP_DEBUG #define sp_log_debug(...) sp_log_msg("DEBUG", SP_LOG_DEBUG, __VA_ARGS__) #else @@ -42,15 +44,14 @@ #define GET_SUFFIX(x) (x == 1) ? "st" : ((x == 2) ? "nd" : "th") -void sp_log_msg(char const *feature, char const *level, const char *fmt, ...); +void sp_log_msg(char const *feature, int type, const char *fmt, ...); int compute_hash(const char *const filename, char *file_hash); const zend_string *sp_zval_to_zend_string(zval *); bool sp_match_value(const zend_string *, const zend_string *, const sp_pcre *); bool sp_match_array_key(const zval *, const zend_string *, const sp_pcre *); bool sp_match_array_value(const zval *, const zend_string *, const sp_pcre *); void sp_log_disable(const char *restrict, const char *restrict, - const zend_string *restrict, const sp_disabled_function *, - unsigned int, const char *restrict); + const zend_string *restrict, const sp_disabled_function *); void sp_log_disable_ret(const char *restrict, const zend_string *restrict, const sp_disabled_function *); int hook_function(const char *, HashTable *, -- cgit v1.3