]> git.ipfire.org Git - thirdparty/squid.git/blame - src/tests/stub_debug.cc
Maintenance: Removed most NULLs using modernize-use-nullptr (#1075)
[thirdparty/squid.git] / src / tests / stub_debug.cc
CommitLineData
4e0938ef 1/*
bf95c10a 2 * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
4e0938ef
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
25f98340
AJ
9/*
10 * A stub implementation of the Debug.h API.
11 * For use by test binaries which do not need the full context debugging
54311b70
FC
12 *
13 * Note: it doesn't use the STUB API as the functions defined here must
14 * not abort the unit test.
25f98340 15 */
f7f3304a 16#include "squid.h"
675b8408 17#include "debug/Stream.h"
25f98340 18
675b8408 19#define STUB_API "debug/libdebug.la"
0c7e529e 20#include "tests/STUB.h"
25f98340
AJ
21
22char *Debug::debugOptions;
aee3523a 23char *Debug::cache_log= nullptr;
25f98340
AJ
24int Debug::rotateNumber = 0;
25int Debug::Levels[MAX_DEBUG_SECTIONS];
25f98340 26int Debug::override_X = 0;
25f98340 27bool Debug::log_syslog = false;
e863656d 28void Debug::ForceAlert() STUB
25f98340 29
0c7e529e
AR
30void ResyncDebugLog(FILE *) STUB
31
32FILE *
33DebugStream()
34{
35 return stderr;
36}
37
25f98340
AJ
38void
39_db_rotate_log(void)
40{}
41
61be1d8e
AR
42void
43Debug::LogMessage(const Context &context)
25f98340 44{
61be1d8e
AR
45 if (context.level > DBG_IMPORTANT)
46 return;
25f98340 47
61be1d8e 48 if (!stderr)
25f98340
AJ
49 return;
50
61be1d8e
AR
51 fprintf(stderr, "%s| %s\n",
52 "stub time", // debugLogTime(squid_curtime),
53 context.buf.str().c_str());
25f98340
AJ
54}
55
61be1d8e
AR
56bool Debug::StderrEnabled() STUB_RETVAL(false)
57void Debug::PrepareToDie() STUB
58
014adac1
AR
59void
60Debug::parseOptions(char const *)
61{}
bfa09779 62
014adac1 63Debug::Context *Debug::Current = nullptr;
25f98340 64
014adac1 65Debug::Context::Context(const int aSection, const int aLevel):
61be1d8e 66 section(aSection),
014adac1
AR
67 level(aLevel),
68 sectionLevel(Levels[aSection]),
caf785dc
AR
69 upper(Current),
70 forceAlert(false)
25f98340 71{
014adac1
AR
72 buf.setf(std::ios::fixed);
73 buf.precision(2);
25f98340
AJ
74}
75
014adac1
AR
76std::ostringstream &
77Debug::Start(const int section, const int level)
25f98340 78{
014adac1
AR
79 Current = new Context(section, level);
80 return Current->buf;
25f98340
AJ
81}
82
014adac1
AR
83void
84Debug::Finish()
25f98340 85{
014adac1 86 if (Current) {
61be1d8e 87 LogMessage(*Current);
014adac1
AR
88 delete Current;
89 Current = nullptr;
90 }
25f98340 91}
be039a68 92
e863656d
CT
93std::ostream&
94ForceAlert(std::ostream& s)
95{
96 return s;
97}
98