diff options
author | Dmitry Stogov <dmitry@zend.com> | 2013-03-16 00:41:46 +0400 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2013-03-16 00:41:46 +0400 |
commit | 34d3202edac0a56b91eb8a305fc1801bbd9b7653 (patch) | |
tree | ddea0913d86ecec2962f9e770d9de787c1fd6348 /ext/opcache/zend_accelerator_debug.c | |
parent | b1dbfb73571b051fef055dc371e05163cf73eb8b (diff) | |
parent | 8d35170c5fe9b9c0c864b7a6c4dc6b0149809569 (diff) | |
download | php-git-34d3202edac0a56b91eb8a305fc1801bbd9b7653.tar.gz |
Merge Zend Optimizer+
git-subtree-dir: ext/opcache
git-subtree-mainline: b1dbfb73571b051fef055dc371e05163cf73eb8b
git-subtree-split: 8d35170c5fe9b9c0c864b7a6c4dc6b0149809569
Diffstat (limited to 'ext/opcache/zend_accelerator_debug.c')
-rw-r--r-- | ext/opcache/zend_accelerator_debug.c | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/ext/opcache/zend_accelerator_debug.c b/ext/opcache/zend_accelerator_debug.c new file mode 100644 index 0000000000..1234c0fc93 --- /dev/null +++ b/ext/opcache/zend_accelerator_debug.c @@ -0,0 +1,99 @@ +/* + +----------------------------------------------------------------------+ + | Zend Optimizer+ | + +----------------------------------------------------------------------+ + | Copyright (c) 1998-2013 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Andi Gutmans <andi@zend.com> | + | Zeev Suraski <zeev@zend.com> | + | Stanislav Malyshev <stas@zend.com> | + | Dmitry Stogov <dmitry@zend.com> | + +----------------------------------------------------------------------+ +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> +#include <time.h> +#ifdef ZEND_WIN32 +# include <process.h> +#endif +#include "ZendAccelerator.h" + +void zend_accel_error(int type, const char *format, ...) +{ + va_list args; + time_t timestamp; + char *time_string; + FILE * fLog = NULL; + TSRMLS_FETCH(); + + if (type > ZCG(accel_directives).log_verbosity_level) { + return; + } + + timestamp = time(NULL); + time_string = asctime(localtime(×tamp)); + time_string[24] = 0; + + if (!ZCG(accel_directives).error_log || + !*ZCG(accel_directives).error_log || + strcmp(ZCG(accel_directives).error_log, "stderr") == 0) { + + fLog = stderr; + } else { + fLog = fopen(ZCG(accel_directives).error_log, "a+"); + if (!fLog) { + fLog = stderr; + } + } + +#ifdef ZTS + fprintf(fLog, "%s (%lu): ", time_string, (unsigned long)tsrm_thread_id()); +#else + fprintf(fLog, "%s (%d): ", time_string, getpid()); +#endif + + switch (type) { + case ACCEL_LOG_FATAL: + fprintf(fLog, "Fatal Error "); + break; + case ACCEL_LOG_ERROR: + fprintf(fLog, "Error "); + break; + case ACCEL_LOG_WARNING: + fprintf(fLog, "Warning "); + break; + case ACCEL_LOG_INFO: + fprintf(fLog, "Message "); + break; + case ACCEL_LOG_DEBUG: + fprintf(fLog, "Debug "); + break; + } + + va_start(args, format); + vfprintf(fLog, format, args); + va_end(args); + fprintf(fLog, "\n"); + switch (type) { + case ACCEL_LOG_ERROR: + zend_bailout(); + break; + case ACCEL_LOG_FATAL: + exit(-2); + break; + } + fflush(fLog); + if (fLog != stderr) { + fclose(fLog); + } +} |