diff options
| author | Giovanni | 2020-07-22 09:28:42 +0200 |
|---|---|---|
| committer | GitHub | 2020-07-22 09:28:42 +0200 |
| commit | e8d3cd9b26f0b4d660e424f2657f11bbc01eb171 (patch) | |
| tree | fa2b312815be8b50afae7fd0447fe891ab19a487 /src/sp_utils.h | |
| parent | 5a655dda1c3b666adf552fd50f5ebf5f4cbd3ce7 (diff) | |
refactoring sp_log_* (#340)
Co-authored-by: Giovanni Dante Grazioli <giovanni.dantegrazioli@nbs-system.com>
Diffstat (limited to 'src/sp_utils.h')
| -rw-r--r-- | src/sp_utils.h | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/sp_utils.h b/src/sp_utils.h index 91a5a20..744bbff 100644 --- a/src/sp_utils.h +++ b/src/sp_utils.h | |||
| @@ -28,16 +28,25 @@ | |||
| 28 | #define HOOK_FUNCTION_BY_REGEXP(regexp, hook_table, new_function) \ | 28 | #define HOOK_FUNCTION_BY_REGEXP(regexp, hook_table, new_function) \ |
| 29 | hook_regexp(regexp, SNUFFLEUPAGUS_G(hook_table), new_function) | 29 | hook_regexp(regexp, SNUFFLEUPAGUS_G(hook_table), new_function) |
| 30 | 30 | ||
| 31 | #define SP_LOG_SIMULATION 0x100000 | 31 | #define SP_TYPE_LOG (0) |
| 32 | #define SP_LOG_DROP 0x200000 | 32 | #define SP_TYPE_DROP (1) |
| 33 | #define SP_TYPE_SIMULATION (2) | ||
| 34 | |||
| 33 | #define SP_LOG_DEBUG E_NOTICE | 35 | #define SP_LOG_DEBUG E_NOTICE |
| 34 | #define SP_LOG_ERROR E_ERROR | 36 | #define SP_LOG_ERROR E_ERROR |
| 35 | #define SP_LOG_WARN E_WARNING | 37 | #define SP_LOG_WARN E_WARNING |
| 36 | 38 | ||
| 37 | #define sp_log_err(feature, ...) sp_log_msg(feature, SP_LOG_ERROR, __VA_ARGS__) | 39 | #define sp_log_msg(feature, level, ...) sp_log_msgf(feature, level, SP_TYPE_LOG, __VA_ARGS__) |
| 38 | #define sp_log_warn(feature, ...) sp_log_msg(feature, SP_LOG_WARN, __VA_ARGS__) | 40 | #define sp_log_drop(feature, ...) sp_log_msgf(feature, SP_LOG_ERROR, SP_TYPE_DROP, __VA_ARGS__) |
| 41 | #define sp_log_simulation(feature, ...) sp_log_msgf(feature, SP_LOG_WARN, SP_TYPE_SIMULATION, __VA_ARGS__) | ||
| 42 | #define sp_log_auto(feature, is_simulation, ...) sp_log_msgf(feature, \ | ||
| 43 | (is_simulation ? SP_LOG_WARN : SP_LOG_ERROR), \ | ||
| 44 | (is_simulation ? SP_TYPE_SIMULATION : SP_TYPE_DROP), __VA_ARGS__) | ||
| 45 | |||
| 46 | #define sp_log_err(feature, ...) sp_log_msgf(feature, SP_LOG_ERROR, SP_TYPE_LOG, __VA_ARGS__) | ||
| 47 | #define sp_log_warn(feature, ...) sp_log_msgf(feature, SP_LOG_WARN, SP_TYPE_LOG, __VA_ARGS__) | ||
| 39 | #ifdef SP_DEBUG | 48 | #ifdef SP_DEBUG |
| 40 | #define sp_log_debug(...) sp_log_msg("DEBUG", SP_LOG_DEBUG, __VA_ARGS__) | 49 | #define sp_log_debug(...) sp_log_msgf("DEBUG", SP_LOG_DEBUG, SP_TYPE_LOG, __VA_ARGS__) |
| 41 | #else | 50 | #else |
| 42 | #define sp_log_debug(...) | 51 | #define sp_log_debug(...) |
| 43 | #endif | 52 | #endif |
| @@ -45,7 +54,7 @@ | |||
| 45 | #define GET_SUFFIX(x) (x == 1) ? "st" : ((x == 2) ? "nd" : "th") | 54 | #define GET_SUFFIX(x) (x == 1) ? "st" : ((x == 2) ? "nd" : "th") |
| 46 | 55 | ||
| 47 | const char *get_ipaddr(); | 56 | const char *get_ipaddr(); |
| 48 | void sp_log_msg(char const *restrict feature, int type, | 57 | void sp_log_msgf(char const *restrict feature, int level, int type, |
| 49 | const char *restrict fmt, ...); | 58 | const char *restrict fmt, ...); |
| 50 | int compute_hash(const char *const restrict filename, char *restrict file_hash); | 59 | int compute_hash(const char *const restrict filename, char *restrict file_hash); |
| 51 | const zend_string *sp_zval_to_zend_string(const zval *); | 60 | const zend_string *sp_zval_to_zend_string(const zval *); |
