php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
zlog.h
Go to the documentation of this file.
1 /* (c) 2004-2007 Andrei Nigmatulin */
2
3#ifndef ZLOG_H
4#define ZLOG_H 1
5
6#include <stdarg.h>
7#include <sys/types.h>
8
9#define zlog(flags,...) zlog_ex(__func__, __LINE__, flags, __VA_ARGS__)
10#define zlog_msg(flags, prefix, msg) zlog_msg_ex(__func__, __LINE__, flags, prefix, msg)
11
12struct timeval;
13
14typedef unsigned char zlog_bool;
15
16#define ZLOG_TRUE 1
17#define ZLOG_FALSE 0
18
19void zlog_set_external_logger(void (*logger)(int, char *, size_t));
20int zlog_set_fd(int new_fd, zlog_bool is_stderr);
21int zlog_set_level(int new_value);
22int zlog_set_limit(int new_value);
23int zlog_set_buffering(zlog_bool buffering);
24const char *zlog_get_level_name(int log_level);
25void zlog_set_launched(void);
26
27size_t zlog_print_time(struct timeval *tv, char *timebuf, size_t timebuf_len);
28
29void vzlog(const char *function, int line, int flags, const char *fmt, va_list args);
30void zlog_ex(const char *function, int line, int flags, const char *fmt, ...)
31 __attribute__ ((format(printf,4,5)));
32
33void zlog_msg_ex(const char *function, int line, int flags,
34 const char *prefix, const char *msg);
35
36#ifdef HAVE_SYSLOG_H
37extern const int syslog_priorities[];
38#endif
39
40/* keep this same as FCGI_ERROR */
41enum {
47};
48
49#define ZLOG_LEVEL_MASK 7
50
51#define ZLOG_HAVE_ERRNO 0x100
52
53#define ZLOG_SYSERROR (ZLOG_ERROR | ZLOG_HAVE_ERRNO)
54
55#define ZLOG_SYSLOG -2
56
57/* STREAM */
58
60 char *data;
61 size_t size;
62};
63
65 int flags;
66 unsigned int use_syslog:1;
67 unsigned int use_fd:1;
68 unsigned int use_buffer:1;
69 unsigned int use_stderr:1;
70 unsigned int prefix_buffer:1;
71 unsigned int finished:1;
72 unsigned int full:1;
73 unsigned int wrap:1;
74 unsigned int msg_quote:1;
75 unsigned int decorate:1;
76 unsigned int is_stdout:1;
77 int fd;
78 int line;
80 const char *function;
82 size_t len;
84 size_t prefix_len;
91};
92
93void zlog_stream_init(struct zlog_stream *stream, int flags);
94void zlog_stream_init_ex(struct zlog_stream *stream, int flags, int fd);
95void zlog_stream_set_decorating(struct zlog_stream *stream, zlog_bool decorate);
96void zlog_stream_set_wrapping(struct zlog_stream *stream, zlog_bool wrap);
97void zlog_stream_set_is_stdout(struct zlog_stream *stream, zlog_bool is_stdout);
98void zlog_stream_set_child_pid(struct zlog_stream *stream, int child_pid);
99void zlog_stream_set_msg_quoting(struct zlog_stream *stream, zlog_bool quote);
100zlog_bool zlog_stream_set_msg_prefix(struct zlog_stream *stream, const char *fmt, ...)
101 __attribute__ ((format(printf,2,3)));
103 struct zlog_stream *stream, const char *suffix, const char *final_suffix);
104#define zlog_stream_prefix(stream) \
105 zlog_stream_prefix_ex(stream, __func__, __LINE__)
106ssize_t zlog_stream_prefix_ex(struct zlog_stream *stream, const char *function, int line);
107ssize_t zlog_stream_format(struct zlog_stream *stream, const char *fmt, ...)
108 __attribute__ ((format(printf,2,3)));
109ssize_t zlog_stream_vformat(struct zlog_stream *stream, const char *fmt, va_list args);
110ssize_t zlog_stream_str(struct zlog_stream *stream, const char *str, size_t str_len);
112void zlog_stream_destroy(struct zlog_stream *stream);
114
115/* default log limit */
116#define ZLOG_DEFAULT_LIMIT 1024
117/* minimum log limit */
118#define ZLOG_MIN_LIMIT 512
119/* default log buffering */
120#define ZLOG_DEFAULT_BUFFERING 1
121
122#endif
printf(string $format, mixed ... $values)
#define __attribute__(a)
Definition file.h:131
#define prefix
int line
Definition php_ffi.h:54
char * msg
Definition phpdbg.h:289
int fd
Definition phpdbg.h:282
struct timeval tv
Definition session.c:1280
char * data
Definition zlog.h:60
size_t size
Definition zlog.h:61
size_t msg_suffix_len
Definition zlog.h:88
int fd
Definition zlog.h:77
unsigned int wrap
Definition zlog.h:73
char * msg_prefix
Definition zlog.h:85
unsigned int use_buffer
Definition zlog.h:68
size_t prefix_len
Definition zlog.h:84
unsigned int use_fd
Definition zlog.h:67
unsigned int finished
Definition zlog.h:71
unsigned int use_stderr
Definition zlog.h:69
const char * function
Definition zlog.h:80
char * msg_suffix
Definition zlog.h:87
unsigned int full
Definition zlog.h:72
char * msg_final_suffix
Definition zlog.h:89
unsigned int use_syslog
Definition zlog.h:66
unsigned int prefix_buffer
Definition zlog.h:70
size_t buf_init_size
Definition zlog.h:83
int child_pid
Definition zlog.h:79
struct zlog_stream_buffer buf
Definition zlog.h:81
size_t len
Definition zlog.h:82
int flags
Definition zlog.h:65
size_t msg_final_suffix_len
Definition zlog.h:90
unsigned int msg_quote
Definition zlog.h:74
unsigned int is_stdout
Definition zlog.h:76
int line
Definition zlog.h:78
unsigned int decorate
Definition zlog.h:75
size_t msg_prefix_len
Definition zlog.h:86
zval * args
function(EX_VAR(opline->result.var))
zlog_bool zlog_stream_finish(struct zlog_stream *stream)
Definition zlog.c:838
ssize_t zlog_stream_str(struct zlog_stream *stream, const char *str, size_t str_len)
Definition zlog.c:748
void zlog_msg_ex(const char *function, int line, int flags, const char *prefix, const char *msg)
Definition zlog.c:272
zlog_bool zlog_stream_close(struct zlog_stream *stream)
Definition zlog.c:878
zlog_bool zlog_stream_set_msg_suffix(struct zlog_stream *stream, const char *suffix, const char *final_suffix)
Definition zlog.c:614
void zlog_stream_destroy(struct zlog_stream *stream)
Definition zlog.c:862
ssize_t zlog_stream_vformat(struct zlog_stream *stream, const char *fmt, va_list args)
Definition zlog.c:724
void zlog_set_launched(void)
Definition zlog.c:71
unsigned char zlog_bool
Definition zlog.h:14
void zlog_stream_init_ex(struct zlog_stream *stream, int flags, int fd)
Definition zlog.c:543
int zlog_set_limit(int new_value)
Definition zlog.c:114
void zlog_stream_init(struct zlog_stream *stream, int flags)
Definition zlog.c:537
void zlog_stream_set_child_pid(struct zlog_stream *stream, int child_pid)
Definition zlog.c:574
int zlog_set_level(int new_value)
Definition zlog.c:103
void zlog_stream_set_msg_quoting(struct zlog_stream *stream, zlog_bool quote)
Definition zlog.c:580
ssize_t zlog_stream_prefix_ex(struct zlog_stream *stream, const char *function, int line)
Definition zlog.c:669
ssize_t zlog_stream_format(struct zlog_stream *stream, const char *fmt,...) __attribute__((format(printf
void zlog_stream_set_decorating(struct zlog_stream *stream, zlog_bool decorate)
Definition zlog.c:550
void zlog_stream_set_is_stdout(struct zlog_stream *stream, zlog_bool is_stdout)
Definition zlog.c:568
const char * zlog_get_level_name(int log_level)
Definition zlog.c:59
void zlog_set_external_logger(void(*logger)(int, char *, size_t))
Definition zlog.c:53
zlog_bool zlog_stream_set_msg_prefix(struct zlog_stream *stream, const char *fmt,...) __attribute__((format(printf
@ ZLOG_DEBUG
Definition zlog.h:42
@ ZLOG_ERROR
Definition zlog.h:45
@ ZLOG_ALERT
Definition zlog.h:46
@ ZLOG_NOTICE
Definition zlog.h:43
@ ZLOG_WARNING
Definition zlog.h:44
void vzlog(const char *function, int line, int flags, const char *fmt, va_list args)
Definition zlog.c:198
void zlog_ex(const char *function, int line, int flags, const char *fmt,...) __attribute__((format(printf
void zlog_stream_set_wrapping(struct zlog_stream *stream, zlog_bool wrap)
Definition zlog.c:562
size_t zlog_print_time(struct timeval *tv, char *timebuf, size_t timebuf_len)
Definition zlog.c:77
int zlog_set_fd(int new_fd, zlog_bool is_stderr)
Definition zlog.c:92
int zlog_set_buffering(zlog_bool buffering)
Definition zlog.c:123