Skip to content

Commit 8ca0cb8

Browse files
committed
BRAYNS-630 Remove spdlog and use fmt.
1 parent f17ee42 commit 8ca0cb8

26 files changed

+65
-71
lines changed

CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@ option(BRAYNS_ENABLE_ATLAS "Build atlas support" ON)
2222
option(BRAYNS_ENABLE_APPS "Build applications" ON)
2323
option(BRAYNS_ENABLE_TESTS "Build unit tests" ON)
2424

25+
find_package(fmt REQUIRED)
2526
find_package(OpenMP REQUIRED)
2627
find_package(ospray REQUIRED)
27-
find_package(rkcommon REQUIRED)
2828
find_package(Poco REQUIRED COMPONENTS Foundation JSON Net NetSSL)
29+
find_package(rkcommon REQUIRED)
2930
find_package(ZLIB REQUIRED)
30-
find_package(spdlog REQUIRED)
3131

3232
if(BRAYNS_ENABLE_CIRCUITS)
3333
find_package(HDF5 REQUIRED)
3434
find_package(HighFive REQUIRED)
35-
find_package(sonata REQUIRED)
3635
find_package(MorphIO REQUIRED)
36+
find_package(sonata REQUIRED)
3737
endif()
3838

3939
if(BRAYNS_ENABLE_ATLAS)

scripts/superbuild/CMakeLists.txt

+11-11
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ option(BRAYNS_ENABLE_INSTALL "Install Brayns with dependencies" OFF)
1414

1515
include(ExternalProject)
1616

17+
ExternalProject_Add(
18+
fmt
19+
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
20+
GIT_TAG 10.2.1
21+
GIT_SHALLOW ON
22+
CMAKE_ARGS
23+
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
24+
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
25+
-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
26+
)
27+
1728
ExternalProject_Add(
1829
libsonata
1930
GIT_REPOSITORY https://github.com/BlueBrain/libsonata.git
@@ -89,17 +100,6 @@ ExternalProject_Add(
89100
-DENABLE_ACTIVERECORD_COMPILER=OFF
90101
)
91102

92-
ExternalProject_Add(
93-
spdlog
94-
GIT_REPOSITORY https://github.com/gabime/spdlog.git
95-
GIT_TAG v1.13.0
96-
GIT_SHALLOW ON
97-
CMAKE_ARGS
98-
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
99-
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
100-
-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
101-
)
102-
103103
if(BRAYNS_ENABLE_INSTALL)
104104
ExternalProject_Add(
105105
Brayns

src/brayns/atlas/io/nrrdloader/header/HeaderEntryParser.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <brayns/core/utils/string/StringSplitter.h>
2626
#include <brayns/core/utils/string/StringTrimmer.h>
2727

28-
#include <spdlog/fmt/bundled/printf.h>
28+
#include <fmt/printf.h>
2929

3030
namespace
3131
{

src/brayns/circuits/api/coloring/methods/MorphologySectionTypeColorMethod.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
#include <algorithm>
3232

33-
#include <spdlog/fmt/fmt.h>
33+
#include <fmt/format.h>
3434

3535
namespace
3636
{

src/brayns/circuits/api/neuron/NeuronMorphologyReader.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
#include "NeuronMorphologyReader.h"
2020

21-
#include <spdlog/fmt/fmt.h>
21+
#include <fmt/format.h>
2222

2323
#include <morphio/morphology.h>
2424
#include <morphio/section.h>

src/brayns/circuits/io/CellPlacementLoader.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include <brayns/core/utils/Log.h>
3535
#include <brayns/core/utils/Timer.h>
3636

37-
#include <spdlog/fmt/fmt.h>
37+
#include <fmt/format.h>
3838

3939
#include <array>
4040
#include <filesystem>

src/brayns/circuits/io/sonataloader/ParameterCheck.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <brayns/circuits/io/sonataloader/data/Names.h>
2424
#include <brayns/circuits/io/sonataloader/data/PopulationType.h>
2525

26-
#include <spdlog/fmt/fmt.h>
26+
#include <fmt/format.h>
2727

2828
#include <filesystem>
2929
#include <unordered_set>

src/brayns/circuits/io/sonataloader/data/detail/Common.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
#include "Common.h"
2020

21-
#include <spdlog/fmt/fmt.h>
21+
#include <fmt/format.h>
2222

2323
namespace sonataloader::detail
2424
{

src/brayns/core/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ set_target_properties(core PROPERTIES OUTPUT_NAME braynsCore)
1111
target_link_libraries(
1212
core
1313
PUBLIC
14+
fmt::fmt
1415
OpenMP::OpenMP_CXX
1516
ospray::ospray
1617
Poco::Foundation
1718
Poco::JSON
1819
Poco::Net
1920
Poco::NetSSL
2021
rkcommon::rkcommon
21-
spdlog::spdlog
2222
PRIVATE
2323
${ZLIB_LIBRARIES}
2424
stb

src/brayns/core/Version.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#include "Version.h"
2323

24-
#include <spdlog/fmt/fmt.h>
24+
#include <fmt/format.h>
2525

2626
namespace brayns
2727
{

src/brayns/core/engine/colormethods/SolidColorMethod.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <brayns/core/engine/components/ColorSolid.h>
2626
#include <brayns/core/engine/components/GeometryViews.h>
2727

28-
#include <spdlog/fmt/fmt.h>
28+
#include <fmt/format.h>
2929

3030
namespace
3131
{

src/brayns/core/engine/systems/GenericColorSystem.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <algorithm>
2424
#include <unordered_set>
2525

26-
#include <spdlog/fmt/fmt.h>
26+
#include <fmt/format.h>
2727

2828
namespace
2929
{

src/brayns/core/json/JsonError.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include <variant>
2727
#include <vector>
2828

29-
#include <spdlog/fmt/fmt.h>
29+
#include <fmt/format.h>
3030

3131
namespace brayns
3232
{

src/brayns/core/json/JsonType.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include <type_traits>
2828
#include <unordered_map>
2929

30-
#include <spdlog/fmt/fmt.h>
30+
#include <fmt/format.h>
3131

3232
#include <Poco/JSON/Array.h>
3333
#include <Poco/JSON/JSONException.h>

src/brayns/core/network/client/ClientRef.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include <functional>
2525
#include <memory>
2626

27-
#include <spdlog/fmt/fmt.h>
27+
#include <fmt/format.h>
2828

2929
#include <brayns/core/network/websocket/IWebSocket.h>
3030

src/brayns/core/network/client/ClientRequest.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#pragma once
2323

24-
#include <spdlog/fmt/fmt.h>
24+
#include <fmt/format.h>
2525

2626
#include <brayns/core/network/websocket/InputPacket.h>
2727

src/brayns/core/network/entrypoint/EntrypointRegistry.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
#include <stdexcept>
2525

26-
#include <spdlog/fmt/fmt.h>
26+
#include <fmt/format.h>
2727

2828
namespace brayns
2929
{

src/brayns/core/network/jsonrpc/JsonRpcException.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#include "JsonRpcException.h"
2323

24-
#include <spdlog/fmt/fmt.h>
24+
#include <fmt/format.h>
2525

2626
namespace
2727
{

src/brayns/core/network/jsonrpc/JsonRpcException.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
#include <stdexcept>
2525

26-
#include <spdlog/fmt/fmt.h>
26+
#include <fmt/format.h>
2727

2828
#include <brayns/core/json/Json.h>
2929

src/brayns/core/network/jsonrpc/JsonRpcParser.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#include "JsonRpcParser.h"
2323

24-
#include <spdlog/fmt/fmt.h>
24+
#include <fmt/format.h>
2525

2626
#include <brayns/core/json/Json.h>
2727

src/brayns/core/network/jsonrpc/JsonRpcRequest.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
#include <string_view>
2525

26-
#include <spdlog/fmt/fmt.h>
26+
#include <fmt/format.h>
2727

2828
#include <brayns/core/network/client/ClientRef.h>
2929
#include <brayns/core/network/jsonrpc/JsonRpcException.h>

src/brayns/core/network/jsonrpc/RequestId.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include <functional>
2525
#include <typeindex>
2626

27-
#include <spdlog/fmt/fmt.h>
27+
#include <fmt/format.h>
2828

2929
#include <brayns/core/json/JsonAdapter.h>
3030

src/brayns/core/network/task/JsonRpcTask.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
#include <cassert>
2525

26-
#include <spdlog/fmt/fmt.h>
26+
#include <fmt/format.h>
2727

2828
#include <brayns/core/utils/Log.h>
2929

src/brayns/core/utils/Log.cpp

+8-22
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,7 @@
2121

2222
#include "Log.h"
2323

24-
#include <spdlog/sinks/stdout_color_sinks.h>
25-
26-
namespace
27-
{
28-
class LoggerFactory
29-
{
30-
public:
31-
static std::shared_ptr<spdlog::logger> createLogger()
32-
{
33-
auto logger = spdlog::stdout_color_mt("Brayns");
34-
logger->set_pattern("%^[%l][%T] %v%$");
35-
#ifdef NDEBUG
36-
logger->set_level(spdlog::level::info);
37-
#else
38-
logger->set_level(spdlog::level::debug);
39-
#endif
40-
return logger;
41-
}
42-
};
43-
} // namespace
24+
#include <iostream>
4425

4526
namespace brayns
4627
{
@@ -60,13 +41,18 @@ EnumMap<LogLevel> EnumReflector<LogLevel>::reflect()
6041

6142
void Log::setLevel(LogLevel level)
6243
{
63-
_logger->set_level(spdlog::level::level_enum(level));
44+
_level = level;
6445
}
6546

6647
void Log::disable()
6748
{
6849
setLevel(LogLevel::Off);
6950
}
7051

71-
std::shared_ptr<spdlog::logger> Log::_logger = LoggerFactory::createLogger();
52+
void Log::_handleMessage(LogLevel level, std::string_view message)
53+
{
54+
auto &levelName = EnumInfo::getName(level);
55+
auto record = fmt::format("[Brayns][{}] {}", levelName, message);
56+
std::cout << record << '\n';
57+
}
7258
} // namespace brayns

src/brayns/core/utils/Log.h

+21-13
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@
2121

2222
#pragma once
2323

24-
#define SPDLOG_HEADER_ONLY
25-
#include <spdlog/fmt/ostr.h>
26-
#include <spdlog/spdlog.h>
24+
#include <string>
25+
#include <string_view>
26+
27+
#include <fmt/format.h>
2728

2829
#include <brayns/core/utils/EnumInfo.h>
2930

@@ -35,14 +36,14 @@ namespace brayns
3536
*/
3637
enum class LogLevel
3738
{
38-
Trace = spdlog::level::trace,
39-
Debug = spdlog::level::debug,
40-
Info = spdlog::level::info,
41-
Warn = spdlog::level::warn,
42-
Error = spdlog::level::err,
43-
Critical = spdlog::level::critical,
44-
Off = spdlog::level::off,
45-
Count = spdlog::level::n_levels
39+
Trace,
40+
Debug,
41+
Info,
42+
Warn,
43+
Error,
44+
Critical,
45+
Off,
46+
Count,
4647
};
4748

4849
template<>
@@ -78,7 +79,12 @@ class Log
7879
template<typename... Args>
7980
static void log(LogLevel level, fmt::format_string<Args...> format, Args &&...args)
8081
{
81-
_logger->log(spdlog::level::level_enum(level), format, std::forward<Args>(args)...);
82+
if (level < _level)
83+
{
84+
return;
85+
}
86+
auto message = fmt::format(format, std::forward<Args>(args)...);
87+
_handleMessage(level, message);
8288
}
8389

8490
/**
@@ -160,6 +166,8 @@ class Log
160166
}
161167

162168
private:
163-
static std::shared_ptr<spdlog::logger> _logger;
169+
static inline LogLevel _level = LogLevel::Info;
170+
171+
static void _handleMessage(LogLevel level, std::string_view message);
164172
};
165173
} // namespace brayns

src/brayns/core/utils/parsing/RangeParser.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <brayns/core/utils/string/StringInfo.h>
2626
#include <brayns/core/utils/string/StringParser.h>
2727

28-
#include <spdlog/fmt/fmt.h>
28+
#include <fmt/format.h>
2929

3030
#include <algorithm>
3131
#include <stdexcept>

0 commit comments

Comments
 (0)