|
BDE 4.39.x Production Release
|
#include <ball_cstdioobserver.h>
This class provides a concrete implementation of the Observer protocol. The publish method of this class outputs the log records that it receives to a FILE * supplied at construction and then flushes the stream.
Public Types | |
| typedef RecordFormatterFunctor::Type | RecordFormatter |
| typedef bsl::allocator< char > | allocator_type |
Public Member Functions | |
| BSLMF_NESTED_TRAIT_DECLARATION (CstdioObserver, bslma::UsesBslmaAllocator) | |
| CstdioObserver (FILE *stream, const allocator_type &allocator=allocator_type()) | |
| ~CstdioObserver () BSLS_KEYWORD_OVERRIDE | |
| void | publish (const bsl::shared_ptr< const Record > &record, const Context &context) BSLS_KEYWORD_OVERRIDE |
| void | releaseRecords () BSLS_KEYWORD_OVERRIDE |
| void | disablePublishInLocalTime () |
| void | enablePublishInLocalTime () |
| void | setFormatFunctor (const RecordFormatter &formatter) |
| int | setFormat (const bsl::string_view &format) |
| bool | isPublishInLocalTimeEnabled () const |
| const bsl::string & | getFormat () const |
| virtual void | publish (const Record &record, const Context &context) |
| virtual void | publish (const bsl::shared_ptr< const Record > &record, const Context &context) |
Public Member Functions inherited from ball::Observer | |
| virtual | ~Observer () |
| typedef bsl::allocator<char> ball::CstdioObserver::allocator_type |
LogRecordFunctor is an alias for the type of the functor used for formatting log records to a stream.
|
explicit |
Create a cstdio observer that transmits log records to the specified stream. Optionally specify an allocator (e.g., the address of a bslma::Allocator object) to supply memory; otherwise, the default allocator is used.
setFormat). | ball::CstdioObserver::~CstdioObserver | ( | ) |
Destroy this cstdio observer.
| ball::CstdioObserver::BSLMF_NESTED_TRAIT_DECLARATION | ( | CstdioObserver | , |
| bslma::UsesBslmaAllocator | |||
| ) |
| void ball::CstdioObserver::disablePublishInLocalTime | ( | ) |
Disable publishing of the timestamp attribute of records in local time by this cstdio observer; henceforth, timestamps will be in UTC time. This method has no effect if publishing in local time is not enabled.
| void ball::CstdioObserver::enablePublishInLocalTime | ( | ) |
Enable publishing of the timestamp attribute of records in local time by this cstdio observer. By default, timestamps are published in UTC time.
| const bsl::string & ball::CstdioObserver::getFormat | ( | ) | const |
Return the format config of the last successful setFormat call.
| bool ball::CstdioObserver::isPublishInLocalTimeEnabled | ( | ) | const |
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).
|
virtual |
Process the specified log record having the specified publishing context. The exact definition of publish depends on the implementing class, though the intention is that the log record (whose publication has occurred according to context) be distributed in a human or machine readable form.
Reimplemented from ball::Observer.
|
virtual |
Process the specified log record having the specified publishing context. Print record and context to the FILE * supplied at construction.
record or context is modified during the execution of this method. Reimplemented from ball::Observer.
Process the specified log record having the specified publishing context.
publish overload instead. Reimplemented from ball::Observer.
|
inlinevirtual |
Discard any shared reference to a Record object that was supplied to the publish method, and is held by this observer.
Reimplemented from ball::Observer.
| int ball::CstdioObserver::setFormat | ( | const bsl::string_view & | format | ) |
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-like, scheme-tagged format. Return zero if the setup with the specified arguments was successful and also save the format to be later retrievable using getFormat. Otherwise (if no matching scheme could be found or the configuration is invalid) return a non-zero value and do not change the log record formatter used by this object.
setFormatFunctor is called. 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. | void ball::CstdioObserver::setFormatFunctor | ( | const RecordFormatter & | formatter | ) |
Set the formatting functor used when writing records to the log of this cstdio observer to the specified formatter functor.
setFormat is called (see ball_recordstringformatter ). 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. formatter, prefer setFormat.