]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/tests/stub_debug.cc
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
;
20 int Debug::TheDepth
= 0;
22 char *Debug::debugOptions
;
23 char *Debug::cache_log
= NULL
;
24 int Debug::rotateNumber
= 0;
25 int Debug::Levels
[MAX_DEBUG_SECTIONS
];
27 int Debug::sectionLevel
;
28 int Debug::override_X
= 0;
29 int Debug::log_stderr
= 1;
30 bool Debug::log_syslog
= false;
33 ctx_enter(const char *)
43 _db_init(const char *, const char *)
47 _db_set_syslog(const char *)
55 _db_print_stderr(const char *format
, va_list args
);
58 _db_print(const char *format
,...)
60 static char f
[BUFSIZ
];
65 va_start(args1
, format
);
66 va_start(args2
, format
);
67 va_start(args3
, format
);
69 snprintf(f
, BUFSIZ
, "%s| %s",
70 "stub time", //debugLogTime(squid_curtime),
73 _db_print_stderr(f
, args2
);
81 _db_print_stderr(const char *format
, va_list args
)
86 vfprintf(stderr
, format
, args
);
89 Debug::OutStream
*Debug::CurrentDebug(NULL
);
95 CurrentDebug
= new Debug::OutStream
;
96 CurrentDebug
->setf(std::ios::fixed
);
97 CurrentDebug
->precision(2);
103 Debug::parseOptions(char const *)
109 std::cerr
<< "debugs: " << CurrentDebug
->str() << std::endl
;
115 Debug::xassert(const char *msg
, const char *file
, int line
)
117 getDebugOut() << "assertion failed: " << file
<< ":" << line
<<
118 ": \"" << msg
<< "\"";
123 SkipBuildPrefix(const char* path
)
129 Raw::print(std::ostream
&os
) const
132 os
<< ' ' << label_
<< '[' << size_
<< ']';
137 // finalize debugging level if no level was set explicitly via minLevel()
138 const int finalLevel
= (level
>= 0) ? level
:
139 (size_
> 40 ? DBG_DATA
: Debug::sectionLevel
);
140 if (finalLevel
<= Debug::sectionLevel
) {
141 os
<< (label_
? '=' : ' ');
142 os
.write(data_
, size_
);