]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/tests/stub_debug.cc
2 * A stub implementation of the Debug.h API.
3 * For use by test binaries which do not need the full context debugging
5 * Note: it doesn't use the STUB API as the functions defined here must
6 * not abort the unit test.
11 FILE *debug_log
= NULL
;
12 int Debug::TheDepth
= 0;
14 char *Debug::debugOptions
;
15 char *Debug::cache_log
= NULL
;
16 int Debug::rotateNumber
= 0;
17 int Debug::Levels
[MAX_DEBUG_SECTIONS
];
19 int Debug::sectionLevel
;
20 int Debug::override_X
= 0;
21 int Debug::log_stderr
= 1;
22 bool Debug::log_syslog
= false;
25 ctx_enter(const char *descr
)
36 _db_init(const char *logfile
, const char *options
)
40 _db_set_syslog(const char *facility
)
48 _db_print_stderr(const char *format
, va_list args
);
51 _db_print(const char *format
,...)
53 static char f
[BUFSIZ
];
58 va_start(args1
, format
);
59 va_start(args2
, format
);
60 va_start(args3
, format
);
62 snprintf(f
, BUFSIZ
, "%s| %s",
63 "stub time", //debugLogTime(squid_curtime),
66 _db_print_stderr(f
, args2
);
74 _db_print_stderr(const char *format
, va_list args
)
79 vfprintf(stderr
, format
, args
);
85 assert(TheDepth
>= 0);
89 *CurrentDebug
<< std::endl
<< "reentrant debuging " << TheDepth
<< "-{";
91 assert(!CurrentDebug
);
92 CurrentDebug
= new std::ostringstream();
93 // set default formatting flags
94 CurrentDebug
->setf(std::ios::fixed
);
95 CurrentDebug
->precision(2);
101 Debug::parseOptions(char const *)
109 assert(TheDepth
>= 0);
110 assert(CurrentDebug
);
112 *CurrentDebug
<< "}-" << TheDepth
<< std::endl
;
114 assert(TheDepth
== 1);
115 _db_print("%s\n", CurrentDebug
->str().c_str());
123 Debug::xassert(const char *msg
, const char *file
, int line
)
127 *CurrentDebug
<< "assertion failed: " << file
<< ":" << line
<<
128 ": \"" << msg
<< "\"";
133 std::ostringstream
*Debug::CurrentDebug (NULL
);
136 SkipBuildPrefix(const char* path
)
142 Raw::print(std::ostream
&os
) const
145 os
<< ' ' << label_
<< '[' << size_
<< ']';
150 // finalize debugging level if no level was set explicitly via minLevel()
151 const int finalLevel
= (level
>= 0) ? level
:
152 (size_
> 40 ? DBG_DATA
: Debug::sectionLevel
);
153 if (finalLevel
<= Debug::sectionLevel
) {
154 os
<< (label_
? '=' : ' ');
155 os
.write(data_
, size_
);