diff options
| author | Ben Fuhrmannek | 2021-08-14 18:44:26 +0200 |
|---|---|---|
| committer | jvoisin | 2021-08-14 18:44:26 +0200 |
| commit | 76424299f8dd69990a7812474803fac9ec52b0b2 (patch) | |
| tree | 14b6044cd13458466fa11dd17e09900451e31400 | |
| parent | 741cab4456f4cf1b12ef40a616797115b547f7d2 (diff) | |
debug log to dup'd stderr / php is closing stderr during shutdown
| -rw-r--r-- | src/snuffleupagus.c | 11 | ||||
| -rw-r--r-- | src/sp_utils.h | 9 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/snuffleupagus.c b/src/snuffleupagus.c index 7bf3649..1ac04d0 100644 --- a/src/snuffleupagus.c +++ b/src/snuffleupagus.c | |||
| @@ -13,6 +13,10 @@ | |||
| 13 | static PHP_INI_MH(OnUpdateConfiguration); | 13 | static PHP_INI_MH(OnUpdateConfiguration); |
| 14 | static inline void sp_op_array_handler(zend_op_array *op); | 14 | static inline void sp_op_array_handler(zend_op_array *op); |
| 15 | 15 | ||
| 16 | #ifdef SP_DEBUG_STDERR | ||
| 17 | int sp_debug_stderr = STDERR_FILENO; | ||
| 18 | #endif | ||
| 19 | |||
| 16 | ZEND_EXTENSION(); | 20 | ZEND_EXTENSION(); |
| 17 | 21 | ||
| 18 | // LCOV_EXCL_START | 22 | // LCOV_EXCL_START |
| @@ -70,6 +74,10 @@ ZEND_DLEXPORT zend_extension zend_extension_entry = { | |||
| 70 | STANDARD_ZEND_EXTENSION_PROPERTIES}; | 74 | STANDARD_ZEND_EXTENSION_PROPERTIES}; |
| 71 | 75 | ||
| 72 | PHP_GINIT_FUNCTION(snuffleupagus) { | 76 | PHP_GINIT_FUNCTION(snuffleupagus) { |
| 77 | #ifdef SP_DEBUG_STDERR | ||
| 78 | sp_debug_stderr = dup(STDERR_FILENO); | ||
| 79 | #endif | ||
| 80 | sp_log_debug("(GINIT)"); | ||
| 73 | snuffleupagus_globals->is_config_valid = SP_CONFIG_NONE; | 81 | snuffleupagus_globals->is_config_valid = SP_CONFIG_NONE; |
| 74 | snuffleupagus_globals->in_eval = 0; | 82 | snuffleupagus_globals->in_eval = 0; |
| 75 | 83 | ||
| @@ -116,6 +124,7 @@ PHP_GINIT_FUNCTION(snuffleupagus) { | |||
| 116 | } | 124 | } |
| 117 | 125 | ||
| 118 | PHP_MINIT_FUNCTION(snuffleupagus) { | 126 | PHP_MINIT_FUNCTION(snuffleupagus) { |
| 127 | sp_log_debug("(MINIT)"); | ||
| 119 | REGISTER_INI_ENTRIES(); | 128 | REGISTER_INI_ENTRIES(); |
| 120 | 129 | ||
| 121 | return SUCCESS; | 130 | return SUCCESS; |
| @@ -244,6 +253,8 @@ PHP_MINFO_FUNCTION(snuffleupagus) { | |||
| 244 | } | 253 | } |
| 245 | 254 | ||
| 246 | static PHP_INI_MH(OnUpdateConfiguration) { | 255 | static PHP_INI_MH(OnUpdateConfiguration) { |
| 256 | sp_log_debug("(OnUpdateConfiguration)"); | ||
| 257 | |||
| 247 | TSRMLS_FETCH(); | 258 | TSRMLS_FETCH(); |
| 248 | 259 | ||
| 249 | if (!new_value || !new_value->len) { | 260 | if (!new_value || !new_value->len) { |
diff --git a/src/sp_utils.h b/src/sp_utils.h index 081f786..b5a1691 100644 --- a/src/sp_utils.h +++ b/src/sp_utils.h | |||
| @@ -51,9 +51,18 @@ | |||
| 51 | sp_log_msgf(feature, SP_LOG_ERROR, SP_TYPE_LOG, __VA_ARGS__) | 51 | sp_log_msgf(feature, SP_LOG_ERROR, SP_TYPE_LOG, __VA_ARGS__) |
| 52 | #define sp_log_warn(feature, ...) \ | 52 | #define sp_log_warn(feature, ...) \ |
| 53 | sp_log_msgf(feature, SP_LOG_WARN, SP_TYPE_LOG, __VA_ARGS__) | 53 | sp_log_msgf(feature, SP_LOG_WARN, SP_TYPE_LOG, __VA_ARGS__) |
| 54 | |||
| 54 | #ifdef SP_DEBUG | 55 | #ifdef SP_DEBUG |
| 56 | |||
| 57 | #ifdef SP_DEBUG_STDERR | ||
| 58 | extern int sp_debug_stderr; | ||
| 59 | #define sp_log_debug(fmt, ...) \ | ||
| 60 | dprintf(sp_debug_stderr, "[snuffleupagus][DEBUG] %s(): " fmt "\n", __FUNCTION__, ##__VA_ARGS__); | ||
| 61 | #else | ||
| 55 | #define sp_log_debug(...) \ | 62 | #define sp_log_debug(...) \ |
| 56 | sp_log_msgf("DEBUG", SP_LOG_DEBUG, SP_TYPE_LOG, __VA_ARGS__) | 63 | sp_log_msgf("DEBUG", SP_LOG_DEBUG, SP_TYPE_LOG, __VA_ARGS__) |
| 64 | #endif | ||
| 65 | |||
| 57 | #else | 66 | #else |
| 58 | #define sp_log_debug(...) | 67 | #define sp_log_debug(...) |
| 59 | #endif | 68 | #endif |
