22#define FPM_LOG_BUFFER 1024
24static char *fpm_log_format =
NULL;
25static int fpm_log_fd = -1;
82 struct key_value_s *kvcopy = calloc(1,
sizeof(*kvcopy));
84 zlog(
ZLOG_ERROR,
"unable to allocate memory while opening the access log");
87 kvcopy->
value = strdup(kv->value);
88 kvcopy->
next = fpm_access_suppress_paths;
89 fpm_access_suppress_paths = kvcopy;
92 if (fpm_log_fd == -1) {
123 if (!log_format && (!fpm_log_format || fpm_log_fd == -1)) {
128 log_format = fpm_log_format;
139 zlog(
ZLOG_WARNING,
"unable to get scoreboard while preparing the access log");
144 zlog(
ZLOG_WARNING,
"[pool %s] Unable to acquire shm slot while preparing the access log", scoreboard->
pool);
150 if (
UNEXPECTED(fpm_access_log_suppress(&proc))) {
172 if (!token && *
s ==
'%') {
174 memset(format,
'\0',
sizeof(format));
191 if (format[0] ==
'\0' || !
strcasecmp(format,
"total")) {
193 tms_total = proc.last_request_cpu.tms_utime + proc.last_request_cpu.tms_stime + proc.last_request_cpu.tms_cutime + proc.last_request_cpu.tms_cstime;
197 tms_total = proc.last_request_cpu.tms_utime + proc.last_request_cpu.tms_cutime;
201 tms_total = proc.last_request_cpu.tms_stime + proc.last_request_cpu.tms_cstime;
204 zlog(
ZLOG_WARNING,
"only 'total', 'user' or 'system' are allowed as a modifier for %%%c ('%s')", *
s, format);
210 len2 =
snprintf(b,
FPM_LOG_BUFFER -
len,
"%.2f", tms_total / fpm_scoreboard_get_tick() / (proc.cpu_duration.tv_sec + proc.cpu_duration.tv_usec / 1000000.) * 100.);
217 if (format[0] ==
'\0' || !
strcasecmp(format,
"seconds")) {
238 zlog(
ZLOG_WARNING,
"only 'seconds', 'milli', 'milliseconds', 'micro' or 'microseconds' are allowed as a modifier for %%%c ('%s')", *
s, format);
245 if (format[0] ==
'\0') {
246 zlog(
ZLOG_WARNING,
"the name of the environment variable must be set between embraces for %%%c", *
s);
277 if (format[0] ==
'\0' || !
strcasecmp(format,
"bytes")) {
295 zlog(
ZLOG_WARNING,
"only 'bytes', 'kilo', 'kilobytes', 'mega' or 'megabytes' are allowed as a modifier for %%%c ('%s')", *
s, format);
308 if (format[0] ==
'\0') {
309 zlog(
ZLOG_WARNING,
"the name of the header must be set between embraces for %%%c", *
s);
316 size_t format_len =
strlen(format);
336 if (h->
header[format_len] !=
':' || h->
header[format_len + 1] !=
' ') {
407 if (format[0] ==
'\0') {
435 if (l >=
sizeof(format) - 1) {
436 l =
sizeof(format) - 1;
457 if (*
s !=
'}' && format[0] !=
'\0') {
513 if (
SG(request_info).content_length > 0) {
518 for (
struct key_value_s *kv = fpm_access_suppress_paths; kv; kv = kv->
next) {
http_response_code(int $response_code=0)
header(string $header, bool $replace=true, int $response_code=0)
strstr(string $haystack, string $needle, bool $before_needle=false)
const char * fcgi_get_last_client_ip(void)
char * fcgi_getenv(fcgi_request *req, const char *var, int var_len)
struct _fcgi_request fcgi_request
memset(ptr, 0, type->size)
int fpm_log_init_child(struct fpm_worker_pool_s *wp)
int fpm_log_open(int reopen)
int fpm_log_write(char *log_format)
void fpm_pctl_kill_all(int signo)
struct fpm_scoreboard_proc_s * fpm_scoreboard_proc_acquire(struct fpm_scoreboard_s *scoreboard, int child_index, int nohang)
void fpm_scoreboard_proc_release(struct fpm_scoreboard_proc_s *proc)
struct fpm_scoreboard_s * fpm_scoreboard_get(void)
struct fpm_worker_pool_s * fpm_worker_all_pools
strftime(string $format, ?int $timestamp=null)
localtime(?int $timestamp=null, bool $associative=false)
unsigned const char * pos
char script_filename[256]
struct key_value_s * access_suppress_paths
struct fpm_worker_pool_config_s * config
struct fpm_worker_pool_s * next
struct key_value_s * next
strcmp(string $string1, string $string2)
#define strcasecmp(s1, s2)
ZEND_API void * zend_llist_get_next_ex(zend_llist *l, zend_llist_position *pos)
ZEND_API void * zend_llist_get_first_ex(zend_llist *l, zend_llist_position *pos)
zend_llist_element * zend_llist_position
#define zend_quiet_write(...)
#define UNEXPECTED(condition)