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

This class provides a concrete implementation of the `Observer` protocol&period; The `publish` method of this class outputs the log records that it receives to a `FILE &ast;` supplied at construction and then flushes the stream&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class CstdioObserver
    : public xref:BloombergLP/ball/Observer.adoc[Observer]
----

== Base Classes

[cols="1,4"]
|===
| Name| Description
| `xref:BloombergLP/ball/Observer.adoc[Observer]`
| This class provides a protocol for receiving and processing log record output&period;
|===

== Type Aliases

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


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/ball/CstdioObserver/2constructor.adoc[`CstdioObserver`]         [.small]#[constructor]#
| Create a cstdio observer that transmits log records to the specified `stream`&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; Note that a default record format is in effect for cstdio logging (see `setFormat`)&period;
| xref:BloombergLP/ball/CstdioObserver/2destructor.adoc[`&#126;CstdioObserver`] [.small]#[destructor]# [.small]#[virtual]#
| Destroy this cstdio observer&period;
| xref:BloombergLP/ball/CstdioObserver/disablePublishInLocalTime.adoc[`disablePublishInLocalTime`] 
| Disable publishing of the timestamp attribute of records in local time by this cstdio observer&semi; henceforth, timestamps will be in UTC time&period; This method has no effect if publishing in local time is not enabled&period;
| xref:BloombergLP/ball/CstdioObserver/enablePublishInLocalTime.adoc[`enablePublishInLocalTime`] 
| Enable publishing of the timestamp attribute of records in local time by this cstdio observer&period; By default, timestamps are published in UTC time&period; Note that this method also affects timestamps for formatters that use them&period;
| xref:BloombergLP/ball/CstdioObserver/getFormat.adoc[`getFormat`] 
| Return the format config of the last successful `setFormat` call&period;
| xref:BloombergLP/ball/CstdioObserver/isPublishInLocalTimeEnabled.adoc[`isPublishInLocalTimeEnabled`] 
| Return `true` if this observer writes the timestamp attribute of records that it publishes in local time by default, and `false` otherwise (in which case timestamps are written by default in UTC time)&period;
| xref:BloombergLP/ball/CstdioObserver/publish-08.adoc[`publish`] 
| `publish` overloads
| xref:BloombergLP/ball/CstdioObserver/releaseRecords.adoc[`releaseRecords`]  [.small]#[virtual]#
| Discard any shared reference to a `Record` object that was supplied to the `publish` method, and is held by this observer&period; Note that this operation should be called if resources underlying the previously provided shared&hyphen;pointers must be released&period; This method intentionally does nothing as no such resources are held&semi; we publish all records immediately&period;
| xref:BloombergLP/ball/CstdioObserver/setFormat.adoc[`setFormat`] 
| Set the formatting functor used when writing records to the log of this cstdio observer to a functor created according to the specified, possibly URI&hyphen;like, scheme&hyphen;tagged `format`&period; Return zero if the setup with the specified arguments was successful and also save the `format` to be later retrievable using `getFormat`&period; Otherwise (if no matching scheme could be found or the configuration is invalid) return a non&hyphen;zero value and do not change the log record formatter used by this object&period; Note that a default format (&quot;n%d %p %t %s %f %l %c %m %un&quot;) is in effect until this method or `setFormatFunctor` is called&period; Also, notice that the observer emits newline characters at the beginning and at the end of a log record by (the) default (format), so the user needs to add them explicitly to (text) format strings to preserve that behavior&period;
| xref:BloombergLP/ball/CstdioObserver/setFormatFunctor.adoc[`setFormatFunctor`] 
| Set the formatting functor used when writing records to the log of this cstdio observer to the specified `formatter` functor&period; Note that a default format (&quot;n%d %p %t %s %f %l %c %m %un&quot;) is in effect until this method or `setFormat` is called (see `ball&lowbar;recordstringformatter`)&period; Also note that the observer emits newline characters at the beginning and at the end of a log record by default, so the user needs to add them explicitly to the format string to preserve this behavior&period; Note that this method is not able to communicate the timezone default settings to the `formatter`, prefer `setFormat`&period;
| xref:BloombergLP/ball/CstdioObserver/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;CstdioObserver, UsesBslmaAllocator&gt;`] 
| Declare that this type uses a `bslma` allocator&period;
|===


== Using Declarations

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/ball/CstdioObserver/publish-02.adoc[`publish`] 
| Import the base&hyphen;class `publish` overloads&period;
|===



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