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 a message format specification supplied either by setJsonFormat or setSimplifiedFormat manipulator or the default format installed by the constructor) and outputs the result to the stream. While 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) it is advised to use the more flexible scheme‐based format selection provided now by every BDE‐made observer.

Synopsis

Declared in <ball_recordjsonformatter.h>

class RecordJsonFormatter;

Type Aliases

Name

Description

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.

allocator_type

This typedef is an alias for the allocator used by this object.

Enums

Name

Description

SpecSyntax

Enumerator to determine the syntax of the specification string.

Member Functions

Name

Description

RecordJsonFormatter [constructor]

Constructors

~RecordJsonFormatter [destructor]

Destroy this object.

operator=

Assignment operators

allocator [deprecated]

DEPRECATED: Use get_allocator().mechanism() instead.

format

Return the message format specification of this record JSON formatter. See {`Record Format Specification`}. Note that the syntax of this string depends on formatSyntax().

formatSyntax

Return the message format specification syntax of this record JSON formatter. See {`Record Format Specification`}.

get_allocator

Return the allocator used by this object to supply memory.

operator()

Format the specified record according to the current format and recordSeparator to the specified stream.

recordSeparator

Return the record separator of this record JSON formatter.

setFormat

DEPRECATED: Use setJsonFormat instead.

setJsonFormat

Set the message format specification (see {`Record Format Specification`}) of this record JSON formatter to the specified JSON‐syntax 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). Note that this is the method used by the json:// scheme.

setRecordSeparator

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".

setSimplifiedFormat

Parse the simplified format specification (see {`Simplified Record Format Specification`}) in the specified `format` and configure this formatter accordingly. Return 0 on success, and a non‐zero value otherwise.

setTimezoneDefault

Set the time zone default for every "timestamp" output without a timezone specified in the format string to the specified timezoneDefault. Note that this method reapplies the current format specification to update all timestamp formatters.

timezoneDefault

Get the time zone default setting.

Static Member Functions

Name

Description

loadJsonSchemeFormatter

This class method configures a formatter for the "json" scheme using the specified format and formatOptions and if successful loads it into the specified output and returns zero. In case configuration fails a non‐zero value is returned and output is not modified.

loadQjsonSchemeFormatter

This class method configures a formatter for the "qjson" scheme using the specified format and formatOptions and if successful loads it into the specified output and returns zero. In case configuration fails a non‐zero value is returned and output is not modified.

Non-Member Functions

Name

Description

operator!=

Return true if the specified lhs and rhs record formatters do not have the same value, and false otherwise. Two record formatters differ in value if their format syntax, format specifications, timezone defaults, or record separators differ.

operator==

Return true if the specified lhs and rhs record formatters have the same value, and false otherwise. Two record formatters have the same value if they have the same format syntax, format specification, timezone default, and record separator.

Created with MrDocs