php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
zend_accelerator_debug.c
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | Zend OPcache |
4 +----------------------------------------------------------------------+
5 | Copyright (c) The PHP Group |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | https://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
15 | Authors: Andi Gutmans <andi@php.net> |
16 | Zeev Suraski <zeev@php.net> |
17 | Stanislav Malyshev <stas@zend.com> |
18 | Dmitry Stogov <dmitry@php.net> |
19 +----------------------------------------------------------------------+
20*/
21
22#include <stdio.h>
23#include <stdlib.h>
24#include <stdarg.h>
25#include <time.h>
26#ifdef ZEND_WIN32
27# include <process.h>
28#endif
29#include "ZendAccelerator.h"
30
31static void zend_accel_error_va_args(int type, const char *format, va_list args)
32{
33 time_t timestamp;
34 char *time_string;
35 FILE * fLog = NULL;
36
37 if (type <= ZCG(accel_directives).log_verbosity_level) {
38
39 timestamp = time(NULL);
40 time_string = asctime(localtime(&timestamp));
41 time_string[24] = 0;
42
43 if (!ZCG(accel_directives).error_log ||
44 !*ZCG(accel_directives).error_log ||
45 strcmp(ZCG(accel_directives).error_log, "stderr") == 0) {
46
47 fLog = stderr;
48 } else {
49 fLog = fopen(ZCG(accel_directives).error_log, "a");
50 if (!fLog) {
51 fLog = stderr;
52 }
53 }
54
55#ifdef ZTS
56 fprintf(fLog, "%s (" ZEND_ULONG_FMT "): ", time_string, (zend_ulong)tsrm_thread_id());
57#else
58 fprintf(fLog, "%s (%d): ", time_string, getpid());
59#endif
60
61 switch (type) {
62 case ACCEL_LOG_FATAL:
63 fprintf(fLog, "Fatal Error ");
64 break;
65 case ACCEL_LOG_ERROR:
66 fprintf(fLog, "Error ");
67 break;
69 fprintf(fLog, "Warning ");
70 break;
71 case ACCEL_LOG_INFO:
72 fprintf(fLog, "Message ");
73 break;
74 case ACCEL_LOG_DEBUG:
75 fprintf(fLog, "Debug ");
76 break;
77 }
78
79 vfprintf(fLog, format, args);
80 fprintf(fLog, "\n");
81
82 fflush(fLog);
83 if (fLog != stderr) {
84 fclose(fLog);
85 }
86 }
87 /* perform error handling even without logging the error */
88 switch (type) {
89 case ACCEL_LOG_ERROR:
91 break;
92 case ACCEL_LOG_FATAL:
93 exit(-2);
94 break;
95 }
96
97}
98
99void zend_accel_error(int type, const char *format, ...)
100{
101 va_list args;
102 va_start(args, format);
103 zend_accel_error_va_args(type, format, args);
104 va_end(args);
105}
106
107ZEND_NORETURN void zend_accel_error_noreturn(int type, const char *format, ...)
108{
109 va_list args;
110 va_start(args, format);
112 zend_accel_error_va_args(type, format, args);
113 va_end(args);
114 /* Should never reach this. */
115 abort();
116}
#define ZCG(v)
fprintf($stream, string $format, mixed ... $values)
vfprintf($stream, string $format, array $values)
fclose($stream)
error_log(string $message, int $message_type=0, ?string $destination=null, ?string $additional_headers=null)
fopen(string $filename, string $mode, bool $use_include_path=false, $context=null)
fflush($stream)
zend_ffi_type * type
Definition ffi.c:3812
#define NULL
Definition gdcache.h:45
time()
localtime(?int $timestamp=null, bool $associative=false)
#define abort()
#define zend_bailout()
Definition zend.h:268
ZEND_NORETURN void zend_accel_error_noreturn(int type, const char *format,...)
void zend_accel_error(int type, const char *format,...)
#define ACCEL_LOG_FATAL
#define ACCEL_LOG_DEBUG
#define ACCEL_LOG_INFO
#define ACCEL_LOG_WARNING
#define ACCEL_LOG_ERROR
exit(string|int $status=0)
strcmp(string $string1, string $string2)
zval * args
#define ZEND_ULONG_FMT
Definition zend_long.h:88
uint32_t zend_ulong
Definition zend_long.h:43
#define ZEND_ASSERT(c)
#define ZEND_NORETURN