Skip to content

Commit 4297543

Browse files
Use spdlog for logging in Gloo
Change Gloo logging macros to use SPDLOG_* macros for logging. This change is largely mechanical - changing the structure of the logging calls to use fmtlib::fmt-style formatting. For example: GLOO_DEBUG("thingOne=", thingOne, " thingTwo=", thingTwo); becomes: GLOO_DEBUG("thingOne={} thingTwo={}", thingOne, thingTwo); However, there are also some less mechanical changes: - Since we don't want to expose spdlog as a public dependency of Gloo, the logging infrastructure is moved into a different header (gloo/common/log.h). This header is not included in GLOO_HDRS, so it is not installed. It should only ever be included by .cc files, or non-public headers. - Due to the previous change, the GLOO_ENFORCE_* macros are moved into a separate header (gloo/common/enforce.h). These are used often in public header files, and are not inherently tied to the logging, so this made the most sense. - gloo/common/log.h (effectively renamed from logging.h) no longer needs a .cc file, as it just passes GLOO_* macros through to the SPDLOG_* macros. - gloo has no init function which must be called first, and can be built as a static library (precluding something like __attribute__((constructor))). For this reason, all logger calls are prefixed with a std::run_once which ensures the logger init/config is performed before the first use of the logger. - gloo/transport/tcp/debug_logger.{h,cc} are deleted, and replaced with a custom fmt formatter implementation in gloo/transport/debug_data.h. - Wherever lists of includes were touched as part of this change, they were reformatted/fixed (e.g. X.h -> cX, alphabetical re-ordering, changing gloo includes from <> to "").
1 parent cc00f41 commit 4297543

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+254
-271
lines changed

docs/errors.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ extend `::gloo::Exception`.
1818
## Assertions
1919
Gloo asserts unexpected errors and logical invariants instead of expecting
2020
callers to handle them. `GLOO_ENFORCE` macros are defined in
21-
[`logging.h`](../gloo/common/logging.h)
21+
[`enforce.h`](../gloo/common/enforce.h)

gloo/algorithm.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include "gloo/algorithm.h"
1010

11-
#include "gloo/common/logging.h"
11+
#include "gloo/common/enforce.h"
1212

1313
namespace gloo {
1414

gloo/allgather.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <array>
1212
#include <cstring>
1313

14-
#include "gloo/common/logging.h"
14+
#include "gloo/common/enforce.h"
1515
#include "gloo/types.h"
1616

1717
namespace gloo {

gloo/allgatherv.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <cstring>
1212
#include <numeric>
1313

14-
#include "gloo/common/logging.h"
14+
#include "gloo/common/enforce.h"
1515
#include "gloo/types.h"
1616

1717
namespace gloo {

gloo/allreduce.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <array>
1313
#include <cstring>
1414

15-
#include "gloo/common/logging.h"
15+
#include "gloo/common/enforce.h"
1616
#include "gloo/math.h"
1717
#include "gloo/types.h"
1818

gloo/alltoall.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#include <cstring>
1212

13-
#include "gloo/common/logging.h"
13+
#include "gloo/common/enforce.h"
1414
#include "gloo/types.h"
1515

1616
namespace gloo {

gloo/alltoall.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#pragma once
1010

11-
#include "gloo/common/logging.h"
11+
#include "gloo/common/enforce.h"
1212
#include "gloo/context.h"
1313
#include "gloo/transport/unbound_buffer.h"
1414

gloo/alltoallv.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <cstring>
1212
#include <numeric>
1313

14-
#include "gloo/common/logging.h"
14+
#include "gloo/common/enforce.h"
1515
#include "gloo/types.h"
1616

1717
namespace gloo {

gloo/alltoallv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#pragma once
1010

11-
#include "gloo/common/logging.h"
11+
#include "gloo/common/enforce.h"
1212
#include "gloo/context.h"
1313
#include "gloo/transport/unbound_buffer.h"
1414

gloo/benchmark/cuda_main.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#include "gloo/benchmark/benchmark.h"
1313
#include "gloo/benchmark/runner.h"
14-
#include "gloo/common/logging.h"
14+
#include "gloo/common/enforce.h"
1515
#include "gloo/cuda_allreduce_bcube.h"
1616
#include "gloo/cuda_allreduce_halving_doubling.h"
1717
#include "gloo/cuda_allreduce_halving_doubling_pipelined.h"

0 commit comments

Comments
 (0)