[#BloombergLP-ball-ObserverFormatterImp]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/ball.adoc[ball]::ObserverFormatterImp
:relfileprefix: ../../
:mrdocs:

This class provides a common implementation of formatting&hyphen;related methods for observer components that support scheme&hyphen;based log record formatting&period; It manages a log record formatter, format configuration strings, and time zone preferences&period; This implementation is intended to be used as a data member in concrete observer classes to provide consistent formatting behavior across different observer types&period;

== Synopsis

Declared in `&lt;ball&lowbar;observerformatterimp&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class ObserverFormatterImp;
----

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/ball/ObserverFormatterImp/RecordFormatter.adoc[`RecordFormatter`] 
| `RecordFormatter` is an alias for the type of the functor used for formatting log records to a stream&period;
| xref:BloombergLP/ball/ObserverFormatterImp/allocator_type.adoc[`allocator&lowbar;type`] 
| This `typedef` is an alias for the allocator used by this object&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/ball/ObserverFormatterImp/2constructor.adoc[`ObserverFormatterImp`]         [.small]#[constructor]#
| Create a `ObserverFormatterImp` instance that formats log records using the specified `format` and `timezoneDefault`&period; It is strongly advised to specify UTC for timezoneDefault&period; Optionally specify an `allocator` (e&period;g&period;, the address of a `bslma&colon;&colon;Allocator` object) to supply memory&semi; otherwise, the default allocator is used&period; The behavior is undefined unless `format` is a valid format string (either one that starts with a scheme or a &quot;text&quot; scheme format)&period; Note that not giving a valid default format string by the observer will result in no logging output if no valid format is set afterwards, so it is a serious error&period;
| xref:BloombergLP/ball/ObserverFormatterImp/formatLogRecord.adoc[`formatLogRecord`] 
| Format the specified log `record` into the specified output `stream` using the current record formatter functor&period;
| xref:BloombergLP/ball/ObserverFormatterImp/getFormat.adoc[`getFormat`] 
| Return the currently active format configuration string of this object&period;
| xref:BloombergLP/ball/ObserverFormatterImp/getTimezoneDefault.adoc[`getTimezoneDefault`] 
| Return the currently active time zone default of this object&period;
| xref:BloombergLP/ball/ObserverFormatterImp/get_allocator.adoc[`get&lowbar;allocator`] 
| Return the allocator used by this object to supply memory&period; Note that if no allocator was supplied at construction the default allocator in effect at construction is used&period;
| xref:BloombergLP/ball/ObserverFormatterImp/setFormat.adoc[`setFormat`] 
| Set the log record format specifications for this object according to the specified `format`&period; Return 0 on success, and a non&hyphen;zero value otherwise&period; This method has no effect on format if `format` is not a valid format specification&period; If `format` does not start with a scheme (it has no &quot;&colon;&sol;&sol;&quot; in it) use the default &quot;text&quot; scheme&period;
| xref:BloombergLP/ball/ObserverFormatterImp/setFormatFunctor.adoc[`setFormatFunctor`] 
| Set the formatting functor used when writing records to the specified `formatter` functor&period; Note that this method is not able to communicate the timezone default settings to the `formatter`, prefer `setFormat`&period;
| xref:BloombergLP/ball/ObserverFormatterImp/setTimezoneDefault.adoc[`setTimezoneDefault`] 
| Set the default time zone used for timestamps that have no timezone preference specified in the format config string&period; This method recreates the formatter used with the new timezone setting and the last successfully&hyphen;set format config string&period; Note that (at the time of writing) the printf&hyphen;style format strings do not have syntax to specify the time zone so for such&hyphen;configured formatters all timestamps will use this time zone default&period;
|===



[.small]#Created with https://www.mrdocs.com[MrDocs]#
