Skip to content

Commit acd2546

Browse files
committed
CBD-6348: [BP] Changes needed for fmt 10.2
Backport changes required for FMT upgrade Change-Id: Ic687ac0d2c784abfac9dd8a3bff2a813af692788 Reviewed-on: https://review.couchbase.org/c/kv_engine/+/234759 Tested-by: Trond Norbye <[email protected]> Well-Formed: Restriction Checker Reviewed-by: Jim Walker <[email protected]>
1 parent 1b41d8b commit acd2546

Some content is hidden

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

59 files changed

+476
-188
lines changed

daemon/cluster_config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,6 @@ class ClusterConfiguration {
8989

9090
std::string to_string(const ClustermapVersion& version);
9191
std::ostream& operator<<(std::ostream& os, const ClustermapVersion& version);
92+
inline auto format_as(const ClustermapVersion& version) {
93+
return to_string(version);
94+
}

daemon/connection.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1422,7 +1422,7 @@ Connection::~Connection() {
14221422
LOG_DEBUG("Current tenant use for {}:{} - {}",
14231423
user.name,
14241424
to_string(user.domain),
1425-
tenant->to_json());
1425+
tenant->to_json().dump());
14261426
}
14271427

14281428
if (bev) {

daemon/protocol/mcbp/settings_reload_command_context.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ cb::engine_errc SettingsReloadCommandContext::doSettingsReload() {
263263
cookie.getConnectionId(),
264264
cookie.getEventId(),
265265
cookie.getErrorContext(),
266-
extras);
266+
extras.dump());
267267
return cb::engine_errc::failed;
268268
} catch (const std::exception& exception) {
269269
cookie.setErrorContext(exception.what());

engines/ep/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ SET_PROPERTY(TARGET ep-engine_collections PROPERTY POSITION_INDEPENDENT_CODE 1)
230230

231231
kv_enable_pch(ep-engine_collections)
232232

233-
target_link_libraries(ep-engine_collections PRIVATE platform)
233+
target_link_libraries(ep-engine_collections PUBLIC fmt::fmt PRIVATE platform)
234234

235235
TARGET_INCLUDE_DIRECTORIES(ep-engine_collections
236236
PUBLIC
@@ -628,7 +628,6 @@ if(CB_ENABLE_HEADER_INCLUDE_CHECK)
628628

629629
# List of headers to ignore / not attempt to compile
630630
list(REMOVE_ITEM ep_headers
631-
src/bucket_logger_impl.h # Included via bucket_logger.h
632631
src/config.cmake.h # XXXX
633632
src/tasks.def.h # X-Macro file; cannot be compiled by itself
634633
)

engines/ep/src/bucket_logger.h

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#pragma once
1313

1414
#include "spdlog/logger.h"
15+
#include <fmt/core.h>
16+
#include <spdlog/fmt/ostr.h>
1517

1618
class EventuallyPersistentEngine;
1719

@@ -296,4 +298,98 @@ std::shared_ptr<BucketLogger>& getGlobalBucketLogger();
296298
#define EP_LOG_CRITICAL_RAW(msg) \
297299
EP_LOG_RAW(spdlog::level::level_enum::critical, msg)
298300

299-
#include "bucket_logger_impl.h"
301+
template <typename S, typename... Args>
302+
void BucketLogger::log(spdlog::level::level_enum lvl,
303+
const S& fmt,
304+
Args&&... args) {
305+
if (!should_log(lvl)) {
306+
return;
307+
}
308+
309+
#if FMT_VERSION < 100000
310+
logInner(lvl, fmt, fmt::make_args_checked<Args...>(fmt, args...));
311+
#else
312+
logInner(lvl, fmt, fmt::make_format_args(args...));
313+
#endif
314+
}
315+
316+
template <typename... Args>
317+
void BucketLogger::log(spdlog::level::level_enum lvl, const char* msg) {
318+
if (!should_log(lvl)) {
319+
return;
320+
}
321+
logInner(lvl, msg, {});
322+
}
323+
324+
template <typename T>
325+
void BucketLogger::log(spdlog::level::level_enum lvl, const T& msg) {
326+
if (!should_log(lvl)) {
327+
return;
328+
}
329+
330+
#if FMT_VERSION < 100000
331+
logInner(lvl, "{}", fmt::make_args_checked<T>("{}", msg));
332+
#else
333+
logInner(lvl, "{}", fmt::make_format_args(msg));
334+
#endif
335+
}
336+
337+
template <typename... Args>
338+
void BucketLogger::trace(const char* fmt, const Args&... args) {
339+
log(spdlog::level::trace, fmt, args...);
340+
}
341+
342+
template <typename... Args>
343+
void BucketLogger::debug(const char* fmt, const Args&... args) {
344+
log(spdlog::level::debug, fmt, args...);
345+
}
346+
347+
template <typename... Args>
348+
void BucketLogger::info(const char* fmt, const Args&... args) {
349+
log(spdlog::level::info, fmt, args...);
350+
}
351+
352+
template <typename... Args>
353+
void BucketLogger::warn(const char* fmt, const Args&... args) {
354+
log(spdlog::level::warn, fmt, args...);
355+
}
356+
357+
template <typename... Args>
358+
void BucketLogger::error(const char* fmt, const Args&... args) {
359+
log(spdlog::level::err, fmt, args...);
360+
}
361+
362+
template <typename... Args>
363+
void BucketLogger::critical(const char* fmt, const Args&... args) {
364+
log(spdlog::level::critical, fmt, args...);
365+
}
366+
367+
template <typename T>
368+
void BucketLogger::trace(const T& msg) {
369+
log(spdlog::level::trace, msg);
370+
}
371+
372+
template <typename T>
373+
void BucketLogger::debug(const T& msg) {
374+
log(spdlog::level::debug, msg);
375+
}
376+
377+
template <typename T>
378+
void BucketLogger::info(const T& msg) {
379+
log(spdlog::level::info, msg);
380+
}
381+
382+
template <typename T>
383+
void BucketLogger::warn(const T& msg) {
384+
log(spdlog::level::warn, msg);
385+
}
386+
387+
template <typename T>
388+
void BucketLogger::error(const T& msg) {
389+
log(spdlog::level::err, msg);
390+
}
391+
392+
template <typename T>
393+
void BucketLogger::critical(const T& msg) {
394+
log(spdlog::level::critical, msg);
395+
}

engines/ep/src/bucket_logger_impl.h

Lines changed: 0 additions & 103 deletions
This file was deleted.

engines/ep/src/collections/collection_persisted_stats.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,8 @@ struct PersistedStats {
6363
std::ostream& operator<<(std::ostream& os, const PersistedStats& ps);
6464

6565
} // namespace Collections::VB
66+
#include <fmt/ostream.h>
67+
#if FMT_VERSION >= 100000
68+
template <>
69+
struct fmt::formatter<Collections::VB::PersistedStats> : ostream_formatter {};
70+
#endif

engines/ep/src/collections/collections_types.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,11 @@ std::ostream& operator<<(std::ostream& os, const CollectionMetaData& meta) {
213213
}
214214

215215
std::ostream& operator<<(std::ostream& os, const ScopeMetaData& meta) {
216-
os << "sid:" << meta.sid << ",name:" << meta.name;
216+
return os << format_as(meta);
217+
}
217218

218-
return os;
219+
std::string format_as(const ScopeMetaData& meta) {
220+
return fmt::format("sid:{},name:{}", meta.sid, meta.name);
219221
}
220222

221223
} // end namespace Collections

engines/ep/src/collections/collections_types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ struct CollectionMetaData {
204204

205205
std::string to_string(const CollectionMetaData&);
206206
std::ostream& operator<<(std::ostream& os, const CollectionMetaData& meta);
207+
inline auto format_as(const CollectionMetaData& md) {
208+
return to_string(md);
209+
}
207210

208211
/**
209212
* The metadata of a single scope
@@ -220,6 +223,7 @@ struct ScopeMetaData {
220223
};
221224

222225
std::ostream& operator<<(std::ostream& os, const ScopeMetaData& meta);
226+
std::string format_as(const ScopeMetaData& meta);
223227

224228
/**
225229
* For creation of collection SystemEvents - The SystemEventFactory

engines/ep/src/collections/kvstore.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,14 @@ using DroppedCb = std::function<void(
199199
const DiskDocKey& key, int64_t seqno, bool aborted, int64_t pcs)>;
200200

201201
} // namespace Collections::KVStore
202+
203+
#include <fmt/ostream.h>
204+
#if FMT_VERSION >= 100000
205+
template <>
206+
struct fmt::formatter<Collections::KVStore::Manifest> : ostream_formatter {};
207+
template <>
208+
struct fmt::formatter<Collections::KVStore::OpenScope> : ostream_formatter {};
209+
template <>
210+
struct fmt::formatter<Collections::KVStore::OpenCollection>
211+
: ostream_formatter {};
212+
#endif

0 commit comments

Comments
 (0)