Skip to content

Commit 08497aa

Browse files
authored
Remove deprecated debug output functions from 10 source files. (#9657)
* Remove deprecated debug output functions from 10 source files. * Replace use of static with anonymous namespace.
1 parent 6b0d5a4 commit 08497aa

File tree

10 files changed

+380
-265
lines changed

10 files changed

+380
-265
lines changed

include/tscore/Trie.h

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,16 @@
3030
#include "tscore/List.h"
3131
#include "tscore/Diags.h"
3232

33+
class TrieImpl
34+
{
35+
protected:
36+
inline static DbgCtl dbg_ctl_insert{"Trie::Insert"};
37+
inline static DbgCtl dbg_ctl_search{"Trie::Search"};
38+
};
39+
3340
// Note that you should provide the class to use here, but we'll store
3441
// pointers to such objects internally.
35-
template <typename T> class Trie
42+
template <typename T> class Trie : private TrieImpl
3643
{
3744
public:
3845
Trie() { m_root.Clear(); }
@@ -84,7 +91,7 @@ template <typename T> class Trie
8491
ink_zero(children);
8592
}
8693

87-
void Print(const char *debug_tag) const;
94+
void Print(const DbgCtl &dbg_ctl) const;
8895
inline Node *
8996
GetChild(char index) const
9097
{
@@ -142,9 +149,9 @@ Trie<T>::Insert(const char *key, T *value, int rank, int key_len /* = -1 */)
142149
int i = 0;
143150

144151
while (true) {
145-
if (is_debug_tag_set("Trie::Insert")) {
146-
Debug("Trie::Insert", "Visiting Node...");
147-
curr_node->Print("Trie::Insert");
152+
if (is_dbg_ctl_enabled(dbg_ctl_insert)) {
153+
Dbg(dbg_ctl_insert, "Visiting Node...");
154+
curr_node->Print(dbg_ctl_insert);
148155
}
149156

150157
if (i == key_len) {
@@ -154,7 +161,7 @@ Trie<T>::Insert(const char *key, T *value, int rank, int key_len /* = -1 */)
154161
next_node = curr_node->GetChild(key[i]);
155162
if (!next_node) {
156163
while (i < key_len) {
157-
Debug("Trie::Insert", "Creating child node for char %c (%d)", key[i], key[i]);
164+
Dbg(dbg_ctl_insert, "Creating child node for char %c (%d)", key[i], key[i]);
158165
curr_node = curr_node->AllocateChild(key[i]);
159166
++i;
160167
}
@@ -165,15 +172,15 @@ Trie<T>::Insert(const char *key, T *value, int rank, int key_len /* = -1 */)
165172
}
166173

167174
if (curr_node->occupied) {
168-
Debug("Trie::Insert", "Cannot insert duplicate!");
175+
Dbg(dbg_ctl_insert, "Cannot insert duplicate!");
169176
return false;
170177
}
171178

172179
curr_node->occupied = true;
173180
curr_node->value = value;
174181
curr_node->rank = rank;
175182
m_value_list.enqueue(curr_node->value);
176-
Debug("Trie::Insert", "inserted new element!");
183+
Dbg(dbg_ctl_insert, "inserted new element!");
177184
return true;
178185
}
179186

@@ -188,9 +195,9 @@ Trie<T>::Search(const char *key, int key_len /* = -1 */) const
188195
int i = 0;
189196

190197
while (curr_node) {
191-
if (is_debug_tag_set("Trie::Search")) {
192-
Debug("Trie::Search", "Visiting node...");
193-
curr_node->Print("Trie::Search");
198+
if (is_dbg_ctl_enabled(dbg_ctl_search)) {
199+
DbgPrint(dbg_ctl_search, "Visiting node...");
200+
curr_node->Print(dbg_ctl_search);
194201
}
195202
if (curr_node->occupied) {
196203
if (!found_node || curr_node->rank <= found_node->rank) {
@@ -205,7 +212,7 @@ Trie<T>::Search(const char *key, int key_len /* = -1 */) const
205212
}
206213

207214
if (found_node) {
208-
Debug("Trie::Search", "Returning element with rank %d", found_node->rank);
215+
Dbg(dbg_ctl_search, "Returning element with rank %d", found_node->rank);
209216
return found_node->value;
210217
}
211218

@@ -250,18 +257,18 @@ Trie<T>::Print() const
250257

251258
template <typename T>
252259
void
253-
Trie<T>::Node::Print(const char *debug_tag) const
260+
Trie<T>::Node::Print(const DbgCtl &dbg_ctl) const
254261
{
255262
if (occupied) {
256-
Debug(debug_tag, "Node is occupied");
257-
Debug(debug_tag, "Node has rank %d", rank);
263+
Dbg(dbg_ctl, "Node is occupied");
264+
Dbg(dbg_ctl, "Node has rank %d", rank);
258265
} else {
259-
Debug(debug_tag, "Node is not occupied");
266+
Dbg(dbg_ctl, "Node is not occupied");
260267
}
261268

262269
for (int i = 0; i < N_NODE_CHILDREN; ++i) {
263270
if (GetChild(i)) {
264-
Debug(debug_tag, "Node has child for char %c", static_cast<char>(i));
271+
Dbg(dbg_ctl, "Node has child for char %c", static_cast<char>(i));
265272
}
266273
}
267274
}

iocore/aio/AIO.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ DiskHandler::mainAIOEvent(int event, Event *e)
639639
if (errno == EINTR)
640640
goto Lagain;
641641
if (errno == EFAULT || errno == ENOSYS)
642-
Debug("aio", "io_getevents failed: %s (%d)", strerror(-ret), -ret);
642+
Dbg(_dbg_ctl_aio, "io_getevents failed: %s (%d)", strerror(-ret), -ret);
643643
}
644644

645645
ink_aiocb *cbs[MAX_AIO_EVENTS];
@@ -658,7 +658,7 @@ DiskHandler::mainAIOEvent(int event, Event *e)
658658

659659
if (ret != num) {
660660
if (ret < 0) {
661-
Debug("aio", "io_submit failed: %s (%d)", strerror(-ret), -ret);
661+
Dbg(_dbg_ctl_aio, "io_submit failed: %s (%d)", strerror(-ret), -ret);
662662
} else {
663663
Fatal("could not submit IOs, io_submit(%p, %d, %p) returned %d", ctx, num, cbs, ret);
664664
}

iocore/aio/I_AIO.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,12 @@ struct DiskHandler : public Continuation {
150150
memset(&ctx, 0, sizeof(ctx));
151151
int ret = io_setup(MAX_AIO_EVENTS, &ctx);
152152
if (ret < 0) {
153-
Debug("aio", "io_setup error: %s (%d)", strerror(-ret), -ret);
153+
Dbg(_dbg_ctl_aio, "io_setup error: %s (%d)", strerror(-ret), -ret);
154154
}
155155
}
156+
157+
private:
158+
inline static DbgCtl _dbg_ctl_aio{"aio"};
156159
};
157160
#endif
158161

0 commit comments

Comments
 (0)