]>
Commit | Line | Data |
---|---|---|
bbc27441 | 1 | /* |
5b74111a | 2 | * Copyright (C) 1996-2018 The Squid Software Foundation and contributors |
bbc27441 AJ |
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 | ||
82b7abe3 AJ |
9 | #ifndef SQUID_SRC_LOG_FILE_H |
10 | #define SQUID_SRC_LOG_FILE_H | |
11 | ||
9f4aecaf | 12 | #include "cbdata.h" |
82b7abe3 AJ |
13 | #include "dlink.h" |
14 | ||
ef364f64 AJ |
15 | #if HAVE_SYS_PARAM_H |
16 | #include <sys/param.h> | |
17 | #endif | |
18 | ||
9d65168e A |
19 | class logfile_buffer_t |
20 | { | |
82b7abe3 AJ |
21 | public: |
22 | char *buf; | |
23 | int size; | |
24 | int len; | |
25 | int written_len; | |
26 | dlink_node node; | |
27 | }; | |
28 | ||
29 | class Logfile; | |
30 | ||
31 | typedef void LOGLINESTART(Logfile *); | |
32 | typedef void LOGWRITE(Logfile *, const char *, size_t len); | |
33 | typedef void LOGLINEEND(Logfile *); | |
34 | typedef void LOGFLUSH(Logfile *); | |
efc23871 | 35 | typedef void LOGROTATE(Logfile *, const int16_t); |
82b7abe3 AJ |
36 | typedef void LOGCLOSE(Logfile *); |
37 | ||
9d65168e A |
38 | class Logfile |
39 | { | |
9f4aecaf | 40 | CBDATA_CLASS(Logfile); |
82b7abe3 AJ |
41 | |
42 | public: | |
9f4aecaf AJ |
43 | explicit Logfile(const char *aPath); |
44 | ~Logfile() {} | |
45 | ||
ef364f64 | 46 | char path[MAXPATHLEN]; |
82b7abe3 AJ |
47 | |
48 | struct { | |
49 | unsigned int fatal; | |
50 | } flags; | |
51 | ||
52 | int64_t sequence_number; ///< Unique sequence number per log line. | |
53 | ||
54 | public: | |
55 | void *data; | |
56 | ||
57 | LOGLINESTART *f_linestart; | |
58 | LOGWRITE *f_linewrite; | |
59 | LOGLINEEND *f_lineend; | |
60 | LOGFLUSH *f_flush; | |
61 | LOGROTATE *f_rotate; | |
62 | LOGCLOSE *f_close; | |
63 | }; | |
64 | ||
65 | /* Legacy API */ | |
82afb125 FC |
66 | Logfile *logfileOpen(const char *path, size_t bufsz, int); |
67 | void logfileClose(Logfile * lf); | |
efc23871 | 68 | void logfileRotate(Logfile * lf, int16_t rotateCount); |
82afb125 FC |
69 | void logfileWrite(Logfile * lf, char *buf, size_t len); |
70 | void logfileFlush(Logfile * lf); | |
71 | void logfilePrintf(Logfile * lf, const char *fmt,...) PRINTF_FORMAT_ARG2; | |
72 | void logfileLineStart(Logfile * lf); | |
73 | void logfileLineEnd(Logfile * lf); | |
82b7abe3 AJ |
74 | |
75 | #endif /* SQUID_SRC_LOG_FILE_H */ | |
f53969cc | 76 |