]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/tests/stub_debug.cc
2 * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
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.
10 * A stub implementation of the Debug.h API.
11 * For use by test binaries which do not need the full context debugging
13 * Note: it doesn't use the STUB API as the functions defined here must
14 * not abort the unit test.
19 #define STUB_API "debug.cc"
20 #include "tests/STUB.h"
22 char *Debug::debugOptions
;
23 char *Debug::cache_log
= NULL
;
24 int Debug::rotateNumber
= 0;
25 int Debug::Levels
[MAX_DEBUG_SECTIONS
];
26 int Debug::override_X
= 0;
27 int Debug::log_stderr
= 1;
28 bool Debug::log_syslog
= false;
29 void Debug::ForceAlert() STUB
31 void StopUsingDebugLog() STUB
32 void ResyncDebugLog(FILE *) STUB
41 ctx_enter(const char *)
51 _db_init(const char *, const char *)
55 _db_set_syslog(const char *)
63 _db_print_stderr(const char *format
, va_list args
);
66 _db_print(const char *format
,...)
68 static char f
[BUFSIZ
];
73 va_start(args1
, format
);
74 va_start(args2
, format
);
75 va_start(args3
, format
);
77 snprintf(f
, BUFSIZ
, "%s| %s",
78 "stub time", //debugLogTime(squid_curtime),
81 _db_print_stderr(f
, args2
);
89 _db_print_stderr(const char *format
, va_list args
)
91 if (1 < Debug::Level())
94 vfprintf(stderr
, format
, args
);
98 Debug::parseOptions(char const *)
101 Debug::Context
*Debug::Current
= nullptr;
103 Debug::Context::Context(const int aSection
, const int aLevel
):
105 sectionLevel(Levels
[aSection
]),
109 buf
.setf(std::ios::fixed
);
114 Debug::Start(const int section
, const int level
)
116 Current
= new Context(section
, level
);
124 _db_print("%s\n", Current
->buf
.str().c_str());
131 ForceAlert(std::ostream
& s
)
137 Raw::print(std::ostream
&os
) const
140 os
<< ' ' << label_
<< '[' << size_
<< ']';
145 // finalize debugging level if no level was set explicitly via minLevel()
146 const int finalLevel
= (level
>= 0) ? level
:
147 (size_
> 40 ? DBG_DATA
: Debug::SectionLevel());
148 if (finalLevel
<= Debug::SectionLevel()) {
149 os
<< (label_
? '=' : ' ');
151 os
.write(data_
, size_
);