1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
// file : web/apache/log -*- C++ -*-
// copyright : Copyright (c) 2014-2015 Code Synthesis Tools CC
// license : MIT; see accompanying LICENSE file
#ifndef WEB_APACHE_LOG
#define WEB_APACHE_LOG
#include <algorithm> // min()
#include <cstdint> // uint64_t
#include <httpd/httpd.h> // request_rec
#include <httpd/http_log.h>
#include <web/module>
namespace web
{
namespace apache
{
class log: public web::log
{
public:
log (request_rec* req) noexcept : req_ (req) {}
virtual void
write (const char* msg) {write (APLOG_ERR, msg);}
// Apache-specific interface.
//
void
write (int level, const char* msg)
{
write (nullptr, 0, nullptr, level, msg);
}
void
write (const char* file,
std::uint64_t line,
const char* func,
int level,
const char* msg)
{
if (file && *file)
file = nullptr; // skip file/line placeholder from log line.
level = std::min (level, APLOG_TRACE8);
if (func)
ap_log_rerror (file,
line,
APLOG_NO_MODULE,
level,
0,
req_,
"[%s]: %s",
func,
msg);
else
// skip function name placeholder from log line
//
ap_log_rerror (file,
line,
APLOG_NO_MODULE,
level,
0,
req_,
": %s",
msg);
}
private:
request_rec* req_;
};
}
}
#endif // WEB_APACHE_LOG
|