]> git.ipfire.org Git - thirdparty/squid.git/blame_incremental - src/tests/stub_debug.cc
Fix SQUID_YESNO 'syntax error near unexpected token' (#2117)
[thirdparty/squid.git] / src / tests / stub_debug.cc
... / ...
CommitLineData
1/*
2 * Copyright (C) 1996-2025 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/*
10 * A stub implementation of the Debug.h API.
11 * For use by test binaries which do not need the full context debugging
12 *
13 * Note: it doesn't use the STUB API as the functions defined here must
14 * not abort the unit test.
15 */
16#include "squid.h"
17#include "debug/Stream.h"
18
19#define STUB_API "debug/libdebug.la"
20#include "tests/STUB.h"
21
22char *Debug::debugOptions;
23char *Debug::cache_log= nullptr;
24int Debug::rotateNumber = 0;
25int Debug::Levels[MAX_DEBUG_SECTIONS];
26int Debug::override_X = 0;
27bool Debug::log_syslog = false;
28void Debug::ForceAlert() STUB
29
30void ResyncDebugLog(FILE *) STUB
31
32FILE *
33DebugStream()
34{
35 return stderr;
36}
37
38void
39_db_rotate_log(void)
40{}
41
42void
43Debug::FormatStream(std::ostream &buf)
44{
45 const static std::ostringstream cleanStream;
46 buf.flags(cleanStream.flags() | std::ios::fixed);
47 buf.width(cleanStream.width());
48 buf.precision(2);
49 buf.fill(' ');
50}
51
52void
53Debug::LogMessage(const Context &context)
54{
55 if (context.level > DBG_IMPORTANT)
56 return;
57
58 if (!stderr)
59 return;
60
61 fprintf(stderr, "%s| %s\n",
62 "stub time", // debugLogTime(current_time),
63 context.buf.str().c_str());
64}
65
66std::ostream &
67Debug::Extra(std::ostream &os)
68{
69 FormatStream(os);
70 os << "\n ";
71 return os;
72}
73
74bool Debug::StderrEnabled() STUB_RETVAL(false)
75void Debug::PrepareToDie() STUB
76
77void
78Debug::parseOptions(char const *)
79{}
80
81Debug::Context *Debug::Current = nullptr;
82
83Debug::Context::Context(const int aSection, const int aLevel):
84 section(aSection),
85 level(aLevel),
86 sectionLevel(Levels[aSection]),
87 upper(Current),
88 forceAlert(false)
89{
90 FormatStream(buf);
91}
92
93std::ostringstream &
94Debug::Start(const int section, const int level)
95{
96 Current = new Context(section, level);
97 return Current->buf;
98}
99
100void
101Debug::Finish()
102{
103 if (Current) {
104 LogMessage(*Current);
105 delete Current;
106 Current = nullptr;
107 }
108}
109
110std::ostream&
111ForceAlert(std::ostream& s)
112{
113 return s;
114}
115