stub_debug.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
3 *
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.
7 */
8
9/*
10 * A stub implementation of the Debug.h API.
11 * For use by test binaries which do not need the full context debugging
12 *
13 * Note: it doesn't use the STUB API as the functions defined here must
14 * not abort the unit test.
15 */
16#include "squid.h"
17#include "debug/Stream.h"
18
19#define STUB_API "debug/libdebug.la"
20#include "tests/STUB.h"
21
23char *Debug::cache_log= nullptr;
26int Debug::override_X = 0;
27bool Debug::log_syslog = false;
29
30void ResyncDebugLog(FILE *) STUB
31
32FILE *
34{
35 return stderr;
36}
37
38void
40{}
41
42void
43Debug::LogMessage(const Context &context)
44{
45 if (context.level > DBG_IMPORTANT)
46 return;
47
48 if (!stderr)
49 return;
50
51 fprintf(stderr, "%s| %s\n",
52 "stub time", // debugLogTime(squid_curtime),
53 context.buf.str().c_str());
54}
55
57void Debug::PrepareToDie() STUB
58
59void
60Debug::parseOptions(char const *)
61{}
62
64
65Debug::Context::Context(const int aSection, const int aLevel):
66 section(aSection),
67 level(aLevel),
68 sectionLevel(Levels[aSection]),
69 upper(Current),
70 forceAlert(false)
71{
72 buf.setf(std::ios::fixed);
73 buf.precision(2);
74}
75
76std::ostringstream &
77Debug::Start(const int section, const int level)
78{
79 Current = new Context(section, level);
80 return Current->buf;
81}
82
83void
85{
86 if (Current) {
88 delete Current;
89 Current = nullptr;
90 }
91}
92
93std::ostream&
94ForceAlert(std::ostream& s)
95{
96 return s;
97}
98
#define false
Definition: GnuRegex.c:240
#define STUB
macro to stub a void function.
Definition: STUB.h:33
#define STUB_RETVAL(x)
Definition: STUB.h:41
meta-information for debugs() or a similar debugging call
Definition: Stream.h:55
std::ostringstream buf
debugs() output sink
Definition: Stream.h:70
Context(const int aSectionLevel, const int aLevel)
Definition: debug.cc:1271
Definition: Stream.h:50
static bool StderrEnabled()
Definition: debug.cc:725
static bool log_syslog
Definition: Stream.h:89
static Context * Current
deepest active context; nil outside debugs()
Definition: Stream.h:178
static void LogMessage(const Context &)
broadcasts debugs() message to the logging channels
Definition: debug.cc:776
static int override_X
Definition: Stream.h:88
static int Levels[MAX_DEBUG_SECTIONS]
Definition: Stream.h:87
static void Finish()
logs output buffer created in Start() and closes debugging context
Definition: debug.cc:1351
static char * debugOptions
Definition: Stream.h:84
static char * cache_log
Definition: Stream.h:85
static std::ostringstream & Start(const int section, const int level)
opens debugging context and returns output buffer
Definition: debug.cc:1327
static int rotateNumber
Definition: Stream.h:86
static void ForceAlert()
configures the active debugging context to write syslog ALERT
Definition: debug.cc:1388
#define MAX_DEBUG_SECTIONS
Definition: Stream.h:37
#define DBG_IMPORTANT
Definition: Stream.h:41
FILE * DebugStream()
Definition: debug.cc:353
void ResyncDebugLog(FILE *newFile)
a hack for low-level file descriptor manipulations in ipcCreate()
Definition: debug.cc:513
void _db_rotate_log(void)
Definition: stub_debug.cc:39
std::ostream & ForceAlert(std::ostream &s)
Definition: stub_debug.cc:94

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors