]> git.ipfire.org Git - thirdparty/squid.git/blame - src/log/File.h
Source Format Enforcement (#532)
[thirdparty/squid.git] / src / log / File.h
CommitLineData
bbc27441 1/*
77b1029d 2 * Copyright (C) 1996-2020 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
19class logfile_buffer_t
20{
82b7abe3
AJ
21public:
22 char *buf;
23 int size;
24 int len;
25 int written_len;
26 dlink_node node;
27};
28
29class Logfile;
30
31typedef void LOGLINESTART(Logfile *);
32typedef void LOGWRITE(Logfile *, const char *, size_t len);
33typedef void LOGLINEEND(Logfile *);
34typedef void LOGFLUSH(Logfile *);
efc23871 35typedef void LOGROTATE(Logfile *, const int16_t);
82b7abe3
AJ
36typedef void LOGCLOSE(Logfile *);
37
9d65168e
A
38class Logfile
39{
9f4aecaf 40 CBDATA_CLASS(Logfile);
82b7abe3
AJ
41
42public:
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
54public:
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
66Logfile *logfileOpen(const char *path, size_t bufsz, int);
67void logfileClose(Logfile * lf);
efc23871 68void logfileRotate(Logfile * lf, int16_t rotateCount);
82afb125
FC
69void logfileWrite(Logfile * lf, char *buf, size_t len);
70void logfileFlush(Logfile * lf);
71void logfilePrintf(Logfile * lf, const char *fmt,...) PRINTF_FORMAT_ARG2;
72void logfileLineStart(Logfile * lf);
73void logfileLineEnd(Logfile * lf);
82b7abe3
AJ
74
75#endif /* SQUID_SRC_LOG_FILE_H */
f53969cc 76