BDE 4.14.0 Production release
|
#include <ball_recordjsonformatter.h>
Public Types | |
typedef bsl::vector< RecordJsonFormatter_FieldFormatter * > | FieldFormatters |
typedef bsl::allocator | allocator_type |
This class provides a function object that formats a log record as JSON text elements and renders them to an output stream. The overloaded operator()
provided by the class formats log record according to JSON message format specification supplied at construction (either by the setFormat
manipulator or by default) and outputs the result to the stream. This functor type is designed to match the function signature expected by many concrete ball::Observer
implementations that publish log records (for example, see ball::FileObserver2::setLogFileFunctor
).
typedef bsl::vector<RecordJsonFormatter_FieldFormatter*> ball::RecordJsonFormatter::FieldFormatters |
FieldFormatters
is an alias for a vector of the RecordJsonFormatter_FieldFormatter
objects, each of which is initialized from the format specification and responsible for rendering one field of a ball::Record
to the output JSON stream.
|
explicit |
Create a record JSON formatter having a default format specification and record separator. Optionally specify an allocator
(e.g., the address of a bslma::Allocator
object) to supply memory; otherwise, the allocator is used. The default format specification is:
The default record separator is "\n".
|
inline |
Create a record JSON formatter initialized to the value of the specified original
record formatter. Optionally specify an allocator
(e.g., the address of a bslma::Allocator
object) to supply memory; otherwise, the default allocator is used.
|
inline |
Create a record JSON formatter having the same format specification and record separator as in the specified original
formatter, and adopting all outstanding memory allocations and the allocator associated with the original
formatter. original
is left in a valid but unspecified state.
|
inline |
Create a record JSON formatter, having the same format specification and record separator as in the specified original
formatter. The format specification of original
is moved to the new object, and all outstanding memory allocations and the specified allocator
are adopted if allocator == original.get_allocator()
. original
is left in a valid but unspecified state.
ball::RecordJsonFormatter::~RecordJsonFormatter | ( | ) |
|
inline |
|
inline |
Return the message format specification of this record JSON formatter. See {Record Format Specification
}.
|
inline |
void ball::RecordJsonFormatter::operator() | ( | bsl::ostream & | stream, |
const Record & | record | ||
) | const |
Format the specified record
according to the current format
and recordSeparator
to the specified stream
.
|
inline |
Assign to this object the format specification and record separator of the specified rhs
object, and return a reference providing modifiable access to this object. The format specification and record separator of rhs
are moved to this object, and all outstanding memory allocations and the allocator associated with rhs
are adopted if get_allocator() == rhs.get_allocator()
. rhs
is left in a valid but unspecified state.
RecordJsonFormatter & ball::RecordJsonFormatter::operator= | ( | const RecordJsonFormatter & | rhs | ) |
Assign to this object the value of the specified rhs
object, and return a reference providing modifiable access to this object.
|
inline |
int ball::RecordJsonFormatter::setFormat | ( | const bsl::string_view & | format | ) |
Set the message format specification (see {Record Format Specification
}) of this record JSON formatter to the specified format
. Return 0 on success, and a non-zero value otherwise (if format
is not valid JSON or not a JSON conforming to the expected schema).
|
inline |
Set the record separator for this record JSON formatter to the specified recordSeparator
. The recordSeparator
will be printed by each invocation of operator()
after the formatted record. The default is a single newline character, "\n".