]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/tests/stub_debug.cc
2 * Copyright (C) 1996-2014 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 *descr
)
44 _db_init(const char *logfile
, const char *options
)
48 _db_set_syslog(const char *facility
)
56 _db_print_stderr(const char *format
, va_list args
);
59 _db_print(const char *format
,...)
61 static char f
[BUFSIZ
];
66 va_start(args1
, format
);
67 va_start(args2
, format
);
68 va_start(args3
, format
);
70 snprintf(f
, BUFSIZ
, "%s| %s",
71 "stub time", //debugLogTime(squid_curtime),
74 _db_print_stderr(f
, args2
);
82 _db_print_stderr(const char *format
, va_list args
)
87 vfprintf(stderr
, format
, args
);
90 Debug::OutStream
*Debug::CurrentDebug(NULL
);
95 assert(TheDepth
>= 0);
99 *CurrentDebug
<< std::endl
<< "reentrant debuging " << TheDepth
<< "-{";
101 assert(!CurrentDebug
);
102 CurrentDebug
= new Debug::OutStream
;
103 // set default formatting flags
104 CurrentDebug
->setf(std::ios::fixed
);
105 CurrentDebug
->precision(2);
107 return *CurrentDebug
;
111 Debug::parseOptions(char const *)
119 assert(TheDepth
>= 0);
120 assert(CurrentDebug
);
122 *CurrentDebug
<< "}-" << TheDepth
<< std::endl
;
124 assert(TheDepth
== 1);
125 _db_print("%s\n", CurrentDebug
->str().c_str());
133 Debug::xassert(const char *msg
, const char *file
, int line
)
137 *CurrentDebug
<< "assertion failed: " << file
<< ":" << line
<<
138 ": \"" << msg
<< "\"";
144 SkipBuildPrefix(const char* path
)
150 Raw::print(std::ostream
&os
) const
153 os
<< ' ' << label_
<< '[' << size_
<< ']';
158 // finalize debugging level if no level was set explicitly via minLevel()
159 const int finalLevel
= (level
>= 0) ? level
:
160 (size_
> 40 ? DBG_DATA
: Debug::sectionLevel
);
161 if (finalLevel
<= Debug::sectionLevel
) {
162 os
<< (label_
? '=' : ' ');
163 os
.write(data_
, size_
);