summarylogtreecommitdiffstats
path: root/ceph-18.2.0-fmt10-fixes.patch
blob: 5d0272f7240d1eda816f09fb175f2dddc71e4e8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
diff --git a/src/common/LogEntry.h b/src/common/LogEntry.h
index 3ddebbd3043..b9096e2850a 100644
--- a/src/common/LogEntry.h
+++ b/src/common/LogEntry.h
@@ -15,7 +15,11 @@
 #ifndef CEPH_LOGENTRY_H
 #define CEPH_LOGENTRY_H
 
+#include <fmt/core.h>
 #include <fmt/format.h>
+#if FMT_VERSION >= 90000
+#include <fmt/ostream.h>
+#endif
 
 #include "include/utime.h"
 #include "msg/msg_fmt.h"
@@ -194,19 +198,17 @@ inline std::ostream& operator<<(std::ostream& out, const LogEntry& e)
              << e.channel << " " << e.prio << " " << e.msg;
 }
 
-template <> struct fmt::formatter<EntityName> : fmt::formatter<std::string_view> {
-  template <typename FormatContext>
-  auto format(const EntityName& e, FormatContext& ctx) {
-    return formatter<std::string_view>::format(e.to_str(), ctx);
-  }
-};
+template <>
+struct fmt::formatter<clog_type>: fmt::ostream_formatter {};
 
-template <> struct fmt::formatter<LogEntry> : fmt::formatter<std::string_view> {
-  template <typename FormatContext>
-  auto format(const LogEntry& e, FormatContext& ctx) {
-    return fmt::format_to(ctx.out(), "{} {} ({}) {} : {} {} {}",
-			  e.stamp, e.name, e.rank, e.seq, e.channel, e.prio, e.msg);
+template <>
+struct fmt::formatter<EntityName> : fmt::formatter<std::string_view> {
+  auto format(const EntityName& e, format_context& ctx) const {
+    return fmt::formatter<std::string_view>::format(e.to_str(), ctx);
   }
 };
 
+template <>
+struct fmt::formatter<LogEntry> : fmt::ostream_formatter {};
+
 #endif
diff --git a/src/include/byteorder.h b/src/include/byteorder.h
index eb6d5e102b4..9a4d0be877a 100644
--- a/src/include/byteorder.h
+++ b/src/include/byteorder.h
@@ -53,3 +53,8 @@ inline ceph_les16 init_les16(__s16 x) {
   v = x;
   return v;
 }
+
+template <typename T>
+auto format_as(ceph_le<T> c) {
+  return (T)c;
+}
diff --git a/src/include/neorados/RADOS_fmt.hpp b/src/include/neorados/RADOS_fmt.hpp
new file mode 100644
index 00000000000..1512ec965fe
--- /dev/null
+++ b/src/include/neorados/RADOS_fmt.hpp
@@ -0,0 +1,16 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+#pragma once
+/**
+ * \file fmtlib formatters for some neorados types
+ */
+
+#include <fmt/core.h>
+#if FMT_VERSION >= 90000
+#include <fmt/ostream.h>
+#endif
+
+#include <include/neorados/RADOS.hpp>
+
+template <>
+struct fmt::formatter<neorados::Object> : fmt::ostream_formatter {};
diff --git a/src/include/types_fmt.h b/src/include/types_fmt.h
new file mode 100644
index 00000000000..3d40085f0b2
--- /dev/null
+++ b/src/include/types_fmt.h
@@ -0,0 +1,16 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+#pragma once
+/**
+ * \file fmtlib formatters for some types.h classes
+ */
+
+#include <fmt/core.h>
+#if FMT_VERSION >= 90000
+#include <fmt/ostream.h>
+#endif
+
+#include <include/types.h>
+
+template <>
+struct fmt::formatter<shard_id_t> : fmt::ostream_formatter {};
diff --git a/src/osd/SnapMapper.cc b/src/osd/SnapMapper.cc
index 7893bc08fdc..e8d34cd25bc 100644
--- a/src/osd/SnapMapper.cc
+++ b/src/osd/SnapMapper.cc
@@ -211,7 +211,7 @@ string SnapMapper::get_prefix(int64_t pool, snapid_t snap)
   return fmt::sprintf("%s%lld_%.16X_",
 		      MAPPING_PREFIX,
 		      pool,
-		      snap);
+		      (uint64_t)snap);
 }
 
 string SnapMapper::to_raw_key(
@@ -650,7 +650,7 @@ string SnapMapper::make_purged_snap_key(int64_t pool, snapid_t last)
   return fmt::sprintf("%s_%lld_%016llx",
 		      PURGED_SNAP_PREFIX,
 		      pool,
-		      last);
+		      (uint64_t)last);
 }
 
 void SnapMapper::make_purged_snap_key_value(
@@ -866,7 +866,7 @@ string SnapMapper::get_legacy_prefix(snapid_t snap)
 {
   return fmt::sprintf("%s%.16X_",
 		      LEGACY_MAPPING_PREFIX,
-		      snap);
+		      (uint64_t)snap);
 }
 
 string SnapMapper::to_legacy_raw_key(
diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h
index afed5fa8351..e374369e8ba 100644
--- a/src/osd/osd_types.h
+++ b/src/osd/osd_types.h
@@ -35,6 +35,7 @@
 #include "msg/msg_types.h"
 #include "include/compat.h"
 #include "include/types.h"
+#include "include/types_fmt.h"
 #include "include/utime.h"
 #include "include/CompatSet.h"
 #include "common/ceph_context.h"
diff --git a/src/tools/neorados.cc b/src/tools/neorados.cc
index 24966d2aee5..44ee1cf199c 100644
--- a/src/tools/neorados.cc
+++ b/src/tools/neorados.cc
@@ -36,6 +36,7 @@
 #include "include/buffer.h" // :(
 
 #include "include/neorados/RADOS.hpp"
+#include "include/neorados/RADOS_fmt.hpp"
 
 using namespace std::literals;