]> git.ipfire.org Git - thirdparty/squid.git/blob - src/log/File.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / log / File.h
1 /*
2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9 #ifndef SQUID_SRC_LOG_FILE_H
10 #define SQUID_SRC_LOG_FILE_H
11
12 #include "dlink.h"
13
14 #if HAVE_SYS_PARAM_H
15 #include <sys/param.h>
16 #endif
17
18 class logfile_buffer_t
19 {
20 public:
21 char *buf;
22 int size;
23 int len;
24 int written_len;
25 dlink_node node;
26 };
27
28 class Logfile;
29
30 typedef void LOGLINESTART(Logfile *);
31 typedef void LOGWRITE(Logfile *, const char *, size_t len);
32 typedef void LOGLINEEND(Logfile *);
33 typedef void LOGFLUSH(Logfile *);
34 typedef void LOGROTATE(Logfile *);
35 typedef void LOGCLOSE(Logfile *);
36
37 class Logfile
38 {
39
40 public:
41 char path[MAXPATHLEN];
42
43 struct {
44 unsigned int fatal;
45 } flags;
46
47 int64_t sequence_number; ///< Unique sequence number per log line.
48
49 public:
50 void *data;
51
52 LOGLINESTART *f_linestart;
53 LOGWRITE *f_linewrite;
54 LOGLINEEND *f_lineend;
55 LOGFLUSH *f_flush;
56 LOGROTATE *f_rotate;
57 LOGCLOSE *f_close;
58 };
59
60 /* Legacy API */
61 Logfile *logfileOpen(const char *path, size_t bufsz, int);
62 void logfileClose(Logfile * lf);
63 void logfileRotate(Logfile * lf);
64 void logfileWrite(Logfile * lf, char *buf, size_t len);
65 void logfileFlush(Logfile * lf);
66 void logfilePrintf(Logfile * lf, const char *fmt,...) PRINTF_FORMAT_ARG2;
67 void logfileLineStart(Logfile * lf);
68 void logfileLineEnd(Logfile * lf);
69
70 #endif /* SQUID_SRC_LOG_FILE_H */
71