Lines Matching refs:buf

129 static inline size_t zlog_truncate_buf(char *buf, size_t buf_size, size_t space_left) /* {{{ */  in zlog_truncate_buf()  argument
131 memcpy(buf + buf_size - sizeof("...") + 1 - space_left, "...", sizeof("...") - 1); in zlog_truncate_buf()
137 int flags, char *buf, size_t buf_size, const char *fmt, va_list args) /* {{{ */ in zlog_external() argument
143 len = vsnprintf(buf, buf_size, fmt, ap); in zlog_external()
147 len = zlog_truncate_buf(buf, buf_size, 0); in zlog_external()
149 external_logger(flags & ZLOG_LEVEL_MASK, buf, len); in zlog_external()
155 char *buf, size_t buf_size, int use_syslog) /* {{{ */ in zlog_buf_prefix() argument
163 len += snprintf(buf, buf_size, "[%s] %s(), line %d: ", in zlog_buf_prefix()
166 len += snprintf(buf, buf_size, "[%s] ", level_names[flags & ZLOG_LEVEL_MASK]); in zlog_buf_prefix()
173 len = zlog_print_time(&tv, buf, buf_size); in zlog_buf_prefix()
177 len += snprintf(buf + len, buf_size - len, "%s: pid %d, %s(), line %d: ", in zlog_buf_prefix()
180 len += snprintf(buf + len, buf_size - len, "%s: %s(), line %d: ", in zlog_buf_prefix()
184 len += snprintf(buf + len, buf_size - len, "%s: ", in zlog_buf_prefix()
195 char buf[MAX_BUF_LENGTH]; in vzlog() local
202 zlog_external(flags, buf, buf_size, fmt, args); in vzlog()
210 len = zlog_buf_prefix(function, line, flags, buf, buf_size, zlog_fd == ZLOG_SYSLOG); in vzlog()
215 len += vsnprintf(buf + len, buf_size - len, fmt, args); in vzlog()
223 len += snprintf(buf + len, buf_size - len, in vzlog()
232 len = zlog_truncate_buf(buf, zlog_limit < buf_size ? zlog_limit : buf_size, 1); in vzlog()
237 buf[len] = '\0'; in vzlog()
238 php_syslog(syslog_priorities[zlog_level], "%s", buf); in vzlog()
239 buf[len++] = '\n'; in vzlog()
243 buf[len++] = '\n'; in vzlog()
244 zend_quiet_write(zlog_fd > -1 ? zlog_fd : STDERR_FILENO, buf, len); in vzlog()
249 zend_quiet_write(STDERR_FILENO, buf, len); in vzlog()
287 char *buf; in zlog_stream_buf_alloc_ex() local
288 size_t size = stream->buf.size ?: stream->buf_init_size; in zlog_stream_buf_alloc_ex()
290 if (stream->buf.data) { in zlog_stream_buf_alloc_ex()
292 buf = realloc(stream->buf.data, size); in zlog_stream_buf_alloc_ex()
295 buf = malloc(size); in zlog_stream_buf_alloc_ex()
298 if (buf == NULL) { in zlog_stream_buf_alloc_ex()
302 stream->buf.data = buf; in zlog_stream_buf_alloc_ex()
303 stream->buf.size = size; in zlog_stream_buf_alloc_ex()
312 if (stream->buf.data && stream->buf.size >= MIN(zlog_limit, stream->buf_init_size)) { in zlog_stream_buf_alloc()
320 struct zlog_stream *stream, const char *buf, size_t len, in zlog_stream_direct_write_ex() argument
324 zend_quiet_write(stream->fd, buf, len); in zlog_stream_direct_write_ex()
331 zend_quiet_write(STDERR_FILENO, buf, len); in zlog_stream_direct_write_ex()
342 struct zlog_stream *stream, const char *buf, size_t len) /* {{{ */ in zlog_stream_direct_write() argument
344 return zlog_stream_direct_write_ex(stream, buf, len, NULL, 0); in zlog_stream_direct_write()
349 struct zlog_stream *stream, const char *buf, size_t len) /* {{{ */ in zlog_stream_unbuffered_write() argument
373 zlog_stream_direct_write(stream, buf, available_len); in zlog_stream_unbuffered_write()
385 stream, buf + available_len, len - available_len); in zlog_stream_unbuffered_write()
403 written = zlog_stream_direct_write_ex(stream, buf, len, append, append_len); in zlog_stream_unbuffered_write()
417 if (stream->buf.size - stream->len <= str_len && in zlog_stream_buf_copy_cstr()
422 memcpy(stream->buf.data + stream->len, str, str_len); in zlog_stream_buf_copy_cstr()
431 if (stream->buf.size - stream->len < 1 && !zlog_stream_buf_alloc_ex(stream, 1)) { in zlog_stream_buf_copy_char()
435 stream->buf.data[stream->len++] = c; in zlog_stream_buf_copy_char()
448 php_syslog(syslog_priorities[zlog_level], "%s", stream->buf.data); in zlog_stream_buf_flush()
455 stream->buf.data + stream->prefix_len, stream->len - stream->prefix_len); in zlog_stream_buf_flush()
458 written = zlog_stream_direct_write(stream, stream->buf.data, stream->len); in zlog_stream_buf_flush()
506 stream->len = zlog_truncate_buf(stream->buf.data, stream->len, 0); in zlog_stream_buf_append()
587 char buf[MAX_WRAPPING_PREFIX_LENGTH]; in zlog_stream_set_msg_prefix() local
596 len = vsnprintf(buf, MAX_WRAPPING_PREFIX_LENGTH - 1, fmt, args); in zlog_stream_set_msg_prefix()
605 memcpy(stream->msg_prefix, buf, len); in zlog_stream_set_msg_prefix()
686 stream->buf.data, stream->buf.size, stream->use_syslog); in zlog_stream_prefix_ex()
852 if (stream->buf.data != NULL) { in zlog_stream_destroy()
853 free(stream->buf.data); in zlog_stream_destroy()