Skip to content

Commit bf62216

Browse files
committed
refactor(log): replace utility/log with imp/log in prod_cons.h and queue.h
- Replace include "libipc/utility/log.h" with "libipc/imp/log.h" - prod_cons.h: Replace ipc::log() calls with LIBIPC_LOG() + log.warning() - Updated 2 force_push() template functions in broadcast implementations - Changed log level from generic log to warning for force_push scenarios - queue.h: Replace ipc::error() calls with LIBIPC_LOG() + log.error() - Updated queue_conn::open() template function - Use type-safe streaming interface instead of printf-style formatting - Remove manual newline characters from log messages
1 parent 2ec1914 commit bf62216

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

src/libipc/prod_cons.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#include "libipc/platform/detail.h"
1212
#include "libipc/circ/elem_def.h"
13-
#include "libipc/utility/log.h"
13+
#include "libipc/imp/log.h"
1414
#include "libipc/utility/utility.h"
1515

1616
namespace ipc {
@@ -242,6 +242,7 @@ struct prod_cons_impl<wr<relat::single, relat::multi, trans::broadcast>> {
242242

243243
template <typename W, typename F, typename E>
244244
bool force_push(W* wrapper, F&& f, E* elems) {
245+
LIBIPC_LOG();
245246
E* el;
246247
epoch_ += ep_incr;
247248
for (unsigned k = 0;;) {
@@ -252,7 +253,7 @@ struct prod_cons_impl<wr<relat::single, relat::multi, trans::broadcast>> {
252253
auto cur_rc = el->rc_.load(std::memory_order_acquire);
253254
circ::cc_t rem_cc = cur_rc & ep_mask;
254255
if (cc & rem_cc) {
255-
ipc::log("force_push: k = %u, cc = %u, rem_cc = %u\n", k, cc, rem_cc);
256+
log.warning("force_push: k = ", k, ", cc = ", cc, ", rem_cc = ", rem_cc);
256257
cc = wrapper->elems()->disconnect_receiver(rem_cc); // disconnect all invalid readers
257258
if (cc == 0) return false; // no reader
258259
}
@@ -375,7 +376,7 @@ struct prod_cons_impl<wr<relat::multi, relat::multi, trans::broadcast>> {
375376
auto cur_rc = el->rc_.load(std::memory_order_acquire);
376377
circ::cc_t rem_cc = cur_rc & rc_mask;
377378
if (cc & rem_cc) {
378-
ipc::log("force_push: k = %u, cc = %u, rem_cc = %u\n", k, cc, rem_cc);
379+
log.warning("force_push: k = ", k, ", cc = ", cc, ", rem_cc = ", rem_cc);
379380
cc = wrapper->elems()->disconnect_receiver(rem_cc); // disconnect all invalid readers
380381
if (cc == 0) return false; // no reader
381382
}

src/libipc/queue.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "libipc/shm.h"
1616
#include "libipc/rw_lock.h"
1717

18-
#include "libipc/utility/log.h"
18+
#include "libipc/imp/log.h"
1919
#include "libipc/platform/detail.h"
2020
#include "libipc/circ/elem_def.h"
2121
#include "libipc/mem/resource.h"
@@ -30,16 +30,17 @@ class queue_conn {
3030

3131
template <typename Elems>
3232
Elems* open(char const * name) {
33+
LIBIPC_LOG();
3334
if (!is_valid_string(name)) {
34-
ipc::error("fail open waiter: name is empty!\n");
35+
log.error("fail open waiter: name is empty!");
3536
return nullptr;
3637
}
3738
if (!elems_h_.acquire(name, sizeof(Elems))) {
3839
return nullptr;
3940
}
4041
auto elems = static_cast<Elems*>(elems_h_.get());
4142
if (elems == nullptr) {
42-
ipc::error("fail acquire elems: %s\n", name);
43+
log.error("fail acquire elems: ", name);
4344
return nullptr;
4445
}
4546
elems->init();

0 commit comments

Comments
 (0)