-
Notifications
You must be signed in to change notification settings - Fork 638
Expand file tree
/
Copy pathstub_debug.cc
More file actions
115 lines (96 loc) · 2.21 KB
/
stub_debug.cc
File metadata and controls
115 lines (96 loc) · 2.21 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
* Copyright (C) 1996-2026 The Squid Software Foundation and contributors
*
* Squid software is distributed under GPLv2+ license and includes
* contributions from numerous individuals and organizations.
* Please see the COPYING and CONTRIBUTORS files for details.
*/
/*
* A stub implementation of the Debug.h API.
* For use by test binaries which do not need the full context debugging
*
* Note: it doesn't use the STUB API as the functions defined here must
* not abort the unit test.
*/
#include "squid.h"
#include "debug/Stream.h"
#define STUB_API "debug/libdebug.la"
#include "tests/STUB.h"
char *Debug::debugOptions;
char *Debug::cache_log= nullptr;
int Debug::rotateNumber = 0;
int Debug::Levels[MAX_DEBUG_SECTIONS];
int Debug::override_X = 0;
bool Debug::log_syslog = false;
void Debug::ForceAlert() STUB
void ResyncDebugLog(FILE *) STUB
FILE *
DebugStream()
{
return stderr;
}
void
_db_rotate_log(void)
{}
void
Debug::FormatStream(std::ostream &buf)
{
const static std::ostringstream cleanStream;
buf.flags(cleanStream.flags() | std::ios::fixed);
buf.width(cleanStream.width());
buf.precision(2);
buf.fill(' ');
}
void
Debug::LogMessage(const Context &context)
{
if (context.level > DBG_IMPORTANT)
return;
if (!stderr)
return;
fprintf(stderr, "%s| %s\n",
"stub time", // debugLogTime(current_time),
context.buf.str().c_str());
}
std::ostream &
Debug::Extra(std::ostream &os)
{
FormatStream(os);
os << "\n ";
return os;
}
bool Debug::StderrEnabled() STUB_RETVAL(false)
void Debug::PrepareToDie() STUB
void
Debug::parseOptions(char const *)
{}
Debug::Context *Debug::Current = nullptr;
Debug::Context::Context(const int aSection, const int aLevel):
section(aSection),
level(aLevel),
sectionLevel(Levels[aSection]),
upper(Current),
forceAlert(false)
{
FormatStream(buf);
}
std::ostringstream &
Debug::Start(const int section, const int level)
{
Current = new Context(section, level);
return Current->buf;
}
void
Debug::Finish()
{
if (Current) {
LogMessage(*Current);
delete Current;
Current = nullptr;
}
}
std::ostream&
ForceAlert(std::ostream& s)
{
return s;
}