]>
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.
15 FILE *debug_log
= NULL
;
16 int Debug::TheDepth
= 0;
18 char *Debug::debugOptions
;
19 char *Debug::cache_log
= NULL
;
20 int Debug::rotateNumber
= 0;
21 int Debug::Levels
[MAX_DEBUG_SECTIONS
];
23 int Debug::override_X
= 0;
24 int Debug::log_stderr
= 1;
25 bool Debug::log_syslog
= false;
28 ctx_enter(const char *descr
)
39 _db_init(const char *logfile
, const char *options
)
43 _db_set_syslog(const char *facility
)
51 _db_print_stderr(const char *format
, va_list args
);
54 _db_print(const char *format
,...)
56 static char f
[BUFSIZ
];
61 va_start(args1
, format
);
62 va_start(args2
, format
);
63 va_start(args3
, format
);
65 snprintf(f
, BUFSIZ
, "%s| %s",
66 "stub time", //debugLogTime(squid_curtime),
69 _db_print_stderr(f
, args2
);
77 _db_print_stderr(const char *format
, va_list args
)
82 vfprintf(stderr
, format
, args
);
88 assert(TheDepth
>= 0);
92 *CurrentDebug
<< std::endl
<< "reentrant debuging " << TheDepth
<< "-{";
94 assert(!CurrentDebug
);
95 CurrentDebug
= new std::ostringstream();
96 // set default formatting flags
97 CurrentDebug
->setf(std::ios::fixed
);
98 CurrentDebug
->precision(2);
100 return *CurrentDebug
;
104 Debug::parseOptions(char const *)
112 assert(TheDepth
>= 0);
113 assert(CurrentDebug
);
115 *CurrentDebug
<< "}-" << TheDepth
<< std::endl
;
117 assert(TheDepth
== 1);
118 _db_print("%s\n", CurrentDebug
->str().c_str());
126 Debug::xassert(const char *msg
, const char *file
, int line
)
130 *CurrentDebug
<< "assertion failed: " << file
<< ":" << line
<<
131 ": \"" << msg
<< "\"";
136 std::ostringstream
*Debug::CurrentDebug (NULL
);
139 SkipBuildPrefix(const char* path
)