]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/tests/stub_debug.cc
d6904a653c7a19bc22ade7040e05a346e098a693
2 * Copyright (C) 1996-2016 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 FILE *debug_log
= NULL
;
21 char *Debug::debugOptions
;
22 char *Debug::cache_log
= NULL
;
23 int Debug::rotateNumber
= 0;
24 int Debug::Levels
[MAX_DEBUG_SECTIONS
];
25 int Debug::override_X
= 0;
26 int Debug::log_stderr
= 1;
27 bool Debug::log_syslog
= false;
30 ctx_enter(const char *)
40 _db_init(const char *, const char *)
44 _db_set_syslog(const char *)
52 _db_print_stderr(const char *format
, va_list args
);
55 _db_print(const char *format
,...)
57 static char f
[BUFSIZ
];
62 va_start(args1
, format
);
63 va_start(args2
, format
);
64 va_start(args3
, format
);
66 snprintf(f
, BUFSIZ
, "%s| %s",
67 "stub time", //debugLogTime(squid_curtime),
70 _db_print_stderr(f
, args2
);
78 _db_print_stderr(const char *format
, va_list args
)
80 if (1 < Debug::Level())
83 vfprintf(stderr
, format
, args
);
87 Debug::parseOptions(char const *)
91 SkipBuildPrefix(const char* path
)
96 Debug::Context
*Debug::Current
= nullptr;
98 Debug::Context::Context(const int aSection
, const int aLevel
):
100 sectionLevel(Levels
[aSection
]),
103 buf
.setf(std::ios::fixed
);
108 Debug::Start(const int section
, const int level
)
110 Current
= new Context(section
, level
);
118 _db_print("%s\n", Current
->buf
.str().c_str());
125 Raw::print(std::ostream
&os
) const
128 os
<< ' ' << label_
<< '[' << size_
<< ']';
133 // finalize debugging level if no level was set explicitly via minLevel()
134 const int finalLevel
= (level
>= 0) ? level
:
135 (size_
> 40 ? DBG_DATA
: Debug::SectionLevel());
136 if (finalLevel
<= Debug::SectionLevel()) {
137 os
<< (label_
? '=' : ' ');
139 os
.write(data_
, size_
);