Skip to content

Commit ffa3238

Browse files
committed
Fix issues
1 parent e7e8001 commit ffa3238

File tree

14 files changed

+162
-131
lines changed

14 files changed

+162
-131
lines changed

include/xrpl/beast/utility/Journal.h

Lines changed: 46 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121
#define BEAST_UTILITY_JOURNAL_H_INCLUDED
2222

2323
#include <xrpl/beast/utility/instrumentation.h>
24+
2425
#include <rapidjson/document.h>
2526

2627
#include <deque>
27-
#include <utility>
28+
#include <optional>
2829
#include <source_location>
2930
#include <sstream>
30-
31+
#include <utility>
3132

3233
namespace ripple::log {
3334
template <typename T>
@@ -75,7 +76,7 @@ operator<<(std::ostream& os, LogField<T> const& param);
7576
template <typename T>
7677
std::ostream&
7778
operator<<(std::ostream& os, LogParameter<T> const& param);
78-
}
79+
} // namespace ripple::log
7980

8081
namespace beast {
8182

@@ -117,7 +118,9 @@ class Journal
117118
public:
118119
template <typename T>
119120
friend std::ostream&
120-
ripple::log::operator<<(std::ostream& os, ripple::log::LogField<T> const& param);
121+
ripple::log::operator<<(
122+
std::ostream& os,
123+
ripple::log::LogField<T> const& param);
121124

122125
template <typename T>
123126
friend std::ostream&
@@ -198,17 +201,18 @@ class Journal
198201

199202
static thread_local JsonLogContext currentJsonLogContext_;
200203

201-
202204
// Invariant: m_sink always points to a valid Sink
203205
Sink* m_sink = nullptr;
204206

205207
static void
206208
initMessageContext(std::source_location location);
207209

208210
static std::string
209-
formatLog(std::string const& message,
211+
formatLog(
212+
std::string const& message,
210213
severities::Severity severity,
211214
std::optional<JsonLogAttributes> const& attributes = std::nullopt);
215+
212216
public:
213217
//--------------------------------------------------------------------------
214218

@@ -300,10 +304,7 @@ class Journal
300304
{
301305
public:
302306
ScopedStream(ScopedStream const& other)
303-
: ScopedStream(
304-
other.m_attributes,
305-
other.m_sink,
306-
other.m_level)
307+
: ScopedStream(other.m_attributes, other.m_sink, other.m_level)
307308
{
308309
}
309310

@@ -390,10 +391,7 @@ class Journal
390391

391392
/** Construct or copy another Stream. */
392393
Stream(Stream const& other)
393-
: Stream(
394-
other.m_attributes,
395-
other.m_sink,
396-
other.m_level)
394+
: Stream(other.m_attributes, other.m_sink, other.m_level)
397395
{
398396
}
399397

@@ -471,8 +469,7 @@ class Journal
471469
if (m_attributes.has_value())
472470
m_attributes = JsonLogAttributes::combine(
473471
other.m_attributes->contextValues_,
474-
m_attributes->contextValues_
475-
);
472+
m_attributes->contextValues_);
476473
else
477474
m_attributes = other.m_attributes;
478475
}
@@ -521,8 +518,7 @@ class Journal
521518
Stream
522519
stream(Severity level) const
523520
{
524-
return Stream(
525-
m_attributes, *m_sink, level);
521+
return Stream(m_attributes, *m_sink, level);
526522
}
527523

528524
/** Returns `true` if any message would be logged at this severity level.
@@ -542,67 +538,49 @@ class Journal
542538
{
543539
if (m_jsonLogsEnabled)
544540
initMessageContext(location);
545-
return {
546-
m_attributes,
547-
*m_sink,
548-
severities::kTrace};
541+
return {m_attributes, *m_sink, severities::kTrace};
549542
}
550543

551544
Stream
552545
debug(std::source_location location = std::source_location::current()) const
553546
{
554547
if (m_jsonLogsEnabled)
555548
initMessageContext(location);
556-
return {
557-
m_attributes,
558-
*m_sink,
559-
severities::kDebug};
549+
return {m_attributes, *m_sink, severities::kDebug};
560550
}
561551

562552
Stream
563553
info(std::source_location location = std::source_location::current()) const
564554
{
565555
if (m_jsonLogsEnabled)
566556
initMessageContext(location);
567-
return {
568-
m_attributes,
569-
*m_sink,
570-
severities::kInfo};
557+
return {m_attributes, *m_sink, severities::kInfo};
571558
}
572559

573560
Stream
574561
warn(std::source_location location = std::source_location::current()) const
575562
{
576-
const char* a = "a";
563+
char const* a = "a";
577564
rapidjson::Value v{a, 1};
578565
if (m_jsonLogsEnabled)
579566
initMessageContext(location);
580-
return {
581-
m_attributes,
582-
*m_sink,
583-
severities::kWarning};
567+
return {m_attributes, *m_sink, severities::kWarning};
584568
}
585569

586570
Stream
587571
error(std::source_location location = std::source_location::current()) const
588572
{
589573
if (m_jsonLogsEnabled)
590574
initMessageContext(location);
591-
return {
592-
m_attributes,
593-
*m_sink,
594-
severities::kError};
575+
return {m_attributes, *m_sink, severities::kError};
595576
}
596577

597578
Stream
598579
fatal(std::source_location location = std::source_location::current()) const
599580
{
600581
if (m_jsonLogsEnabled)
601582
initMessageContext(location);
602-
return {
603-
m_attributes,
604-
*m_sink,
605-
severities::kFatal};
583+
return {m_attributes, *m_sink, severities::kFatal};
606584
}
607585
/** @} */
608586

@@ -614,7 +592,9 @@ class Journal
614592
{
615593
globalLogAttributes_ = JsonLogAttributes{};
616594
}
617-
globalLogAttributes_ = JsonLogAttributes::combine(globalLogAttributes_->contextValues(), globalLogAttributes.contextValues());
595+
globalLogAttributes_ = JsonLogAttributes::combine(
596+
globalLogAttributes_->contextValues(),
597+
globalLogAttributes.contextValues());
618598
}
619599
};
620600

@@ -725,12 +705,12 @@ using logwstream = basic_logstream<wchar_t>;
725705

726706
} // namespace beast
727707

728-
729708
namespace ripple::log {
730709

731710
namespace detail {
732711
template <typename T>
733-
void setJsonValue(
712+
void
713+
setJsonValue(
734714
rapidjson::Value& object,
735715
rapidjson::MemoryPoolAllocator<>& allocator,
736716
char const* name,
@@ -739,7 +719,10 @@ void setJsonValue(
739719
{
740720
using ValueType = std::decay_t<T>;
741721
rapidjson::Value jsonValue;
742-
if constexpr (std::constructible_from<rapidjson::Value, ValueType, rapidjson::MemoryPoolAllocator<>&>)
722+
if constexpr (std::constructible_from<
723+
rapidjson::Value,
724+
ValueType,
725+
rapidjson::MemoryPoolAllocator<>&>)
743726
{
744727
jsonValue = rapidjson::Value{value, allocator};
745728
if (outStream)
@@ -777,12 +760,9 @@ void setJsonValue(
777760
}
778761

779762
object.AddMember(
780-
rapidjson::StringRef(name),
781-
std::move(jsonValue),
782-
allocator
783-
);
784-
}
763+
rapidjson::StringRef(name), std::move(jsonValue), allocator);
785764
}
765+
} // namespace detail
786766

787767
template <typename T>
788768
std::ostream&
@@ -793,7 +773,9 @@ operator<<(std::ostream& os, LogParameter<T> const& param)
793773
detail::setJsonValue(
794774
beast::Journal::currentJsonLogContext_.messageParams,
795775
beast::Journal::currentJsonLogContext_.allocator,
796-
param.name_, param.value_, &os);
776+
param.name_,
777+
param.value_,
778+
&os);
797779
return os;
798780
}
799781

@@ -806,7 +788,9 @@ operator<<(std::ostream& os, LogField<T> const& param)
806788
detail::setJsonValue(
807789
beast::Journal::currentJsonLogContext_.messageParams,
808790
beast::Journal::currentJsonLogContext_.allocator,
809-
param.name_, param.value_, nullptr);
791+
param.name_,
792+
param.value_,
793+
nullptr);
810794
return os;
811795
}
812796

@@ -824,17 +808,19 @@ field(char const* name, T&& value)
824808
return LogField<T>{name, std::forward<T>(value)};
825809
}
826810

827-
template<typename... Pair>
811+
template <typename... Pair>
828812
[[nodiscard]] beast::Journal::JsonLogAttributes
829813
attributes(Pair&&... pairs)
830814
{
831815
beast::Journal::JsonLogAttributes result;
832816

833817
(detail::setJsonValue(
834-
result.contextValues(),
835-
result.allocator(),
836-
pairs.first,
837-
pairs.second, nullptr), ...);
818+
result.contextValues(),
819+
result.allocator(),
820+
pairs.first,
821+
pairs.second,
822+
nullptr),
823+
...);
838824

839825
return result;
840826
}
@@ -846,6 +832,6 @@ attr(char const* name, T&& value)
846832
return std::make_pair(name, std::forward<T>(value));
847833
}
848834

849-
}
835+
} // namespace ripple::log
850836

851837
#endif

include/xrpl/server/detail/BasePeer.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ BasePeer<Handler, Impl>::BasePeer(
8484
, handler_(handler)
8585
, remote_address_(remote_address)
8686
, j_(journal,
87-
log::attributes(
88-
log::attr("PeerID",
89-
[] {
90-
static std::atomic<unsigned> id{0};
91-
return "##" + std::to_string(++id) + " ";
92-
}())))
87+
log::attributes(log::attr(
88+
"PeerID",
89+
[] {
90+
static std::atomic<unsigned> id{0};
91+
return "##" + std::to_string(++id) + " ";
92+
}())))
9393
, work_(executor)
9494
, strand_(executor)
9595
{

src/libxrpl/beast/utility/beast_Journal.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
#include <xrpl/beast/utility/Journal.h>
2121

2222
#include <rapidjson/document.h>
23-
#include <rapidjson/writer.h>
2423
#include <rapidjson/stringbuffer.h>
24+
#include <rapidjson/writer.h>
2525

26-
#include <thread>
27-
#include <ranges>
2826
#include <ios>
2927
#include <ostream>
28+
#include <ranges>
3029
#include <string>
30+
#include <thread>
3131

3232
namespace beast {
3333

@@ -151,8 +151,7 @@ Journal::JsonLogAttributes::setModuleName(std::string const& name)
151151
contextValues_.AddMember(
152152
rapidjson::StringRef("Module"),
153153
rapidjson::Value{name.c_str(), allocator_},
154-
allocator_
155-
);
154+
allocator_);
156155
}
157156

158157
Journal::JsonLogAttributes
@@ -166,7 +165,7 @@ Journal::JsonLogAttributes::combine(
166165

167166
for (auto& member : b.GetObject())
168167
{
169-
auto val = rapidjson::Value{ member.value, result.allocator_ };
168+
auto val = rapidjson::Value{member.value, result.allocator_};
170169
if (result.contextValues_.HasMember(member.name))
171170
{
172171
result.contextValues_[member.name] = std::move(val);
@@ -206,7 +205,8 @@ Journal::formatLog(
206205

207206
if (globalLogAttributes_)
208207
{
209-
for (auto const& [key, value] : globalLogAttributes_->contextValues().GetObject())
208+
for (auto const& [key, value] :
209+
globalLogAttributes_->contextValues().GetObject())
210210
{
211211
rapidjson::Value jsonValue;
212212
jsonValue.CopyFrom(value, currentJsonLogContext_.allocator);

src/test/core/Coroutine_test.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ class Coroutine_test : public beast::unit_test::suite
178178
void
179179
test_yield_and_stop()
180180
{
181-
182181
using namespace std::chrono_literals;
183182
using namespace jtx;
184183

@@ -230,7 +229,10 @@ class Coroutine_test : public beast::unit_test::suite
230229
try
231230
{
232231
th.join();
233-
} catch (const std::exception& e) {}
232+
}
233+
catch (std::exception const& e)
234+
{
235+
}
234236
pass();
235237
}
236238

0 commit comments

Comments
 (0)