diff options
author | Henrik Edin <henrik.edin@mongodb.com> | 2019-11-19 18:41:45 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-11-19 18:41:45 +0000 |
commit | 5976013e3655bd769833f32463048ffd4f45b065 (patch) | |
tree | 610ee929af309b86840539c72c7b3a2047443d58 /src/mongo/logv2/text_formatter.h | |
parent | 0ccd538e9bb21e67cff1150af464318457132a3e (diff) | |
download | mongo-5976013e3655bd769833f32463048ffd4f45b065.tar.gz |
SERVER-44541 Attribute packing and extraction for logv2
Basic integral and floating point types, string, BSONObj supported.
Custom types supported via toString() and toBSON() hooks.
Diffstat (limited to 'src/mongo/logv2/text_formatter.h')
-rw-r--r-- | src/mongo/logv2/text_formatter.h | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/src/mongo/logv2/text_formatter.h b/src/mongo/logv2/text_formatter.h index 4d9a65d7b37..017dbdc34b0 100644 --- a/src/mongo/logv2/text_formatter.h +++ b/src/mongo/logv2/text_formatter.h @@ -29,35 +29,21 @@ #pragma once -#include <boost/log/attributes/value_extraction.hpp> -#include <boost/log/core/record_view.hpp> -#include <boost/log/expressions/message.hpp> -#include <boost/log/utility/formatting_ostream.hpp> - -#include "mongo/logv2/attribute_argument_set.h" -#include "mongo/logv2/attributes.h" -#include "mongo/logv2/log_component.h" -#include "mongo/logv2/log_severity.h" -#include "mongo/logv2/log_tag.h" -#include "mongo/util/time_support.h" - -#include <fmt/format.h> +#include "mongo/logv2/plain_formatter.h" namespace mongo { namespace logv2 { -class TextFormatter { +class TextFormatter : protected PlainFormatter { public: static bool binary() { return false; }; - void operator()(boost::log::record_view const& rec, boost::log::formatting_ostream& strm) { + void operator()(boost::log::record_view const& rec, + boost::log::formatting_ostream& strm) const { using namespace boost::log; - StringData message = extract<StringData>(attributes::message(), rec).get(); - const auto& attrs = extract<AttributeArgumentSet>(attributes::attributes(), rec).get(); - fmt::memory_buffer buffer; fmt::format_to( buffer, @@ -72,9 +58,7 @@ public: strm << "** WARNING: "; } - buffer.clear(); - fmt::internal::vformat_to(buffer, to_string_view(message), attrs._values); - strm.write(buffer.data(), buffer.size()); + PlainFormatter::operator()(rec, strm); } }; |