BDE 4.14.0 Production release
|
#include <ball_recordstringformatter.h>
Public Types | |
typedef bsl::allocator< char > | allocator_type |
Static Public Attributes | |
static const char * | k_DEFAULT_FORMAT |
The default log format specification used by RecordStringFormatter . | |
static const char * | k_BASIC_ATTRIBUTE_FORMAT |
This class provides a value-semantic log record formatter that holds a printf
-style format specification and a timestamp offset. The overloaded operator()
provided by the class formats a given record according to the format specification and outputs the formatted result to a given stream. The timestamp offset of the record formatter is added to each timestamp that is output to the stream.
typedef bsl::allocator<char> ball::RecordStringFormatter::allocator_type |
|
explicit |
|
explicit |
Create a record formatter having a default format specification and a timestamp offset of 0. Optionally specify an allocator
(e.g., the address of a bslma::Allocator
object) to supply memory. If basicAllocator
is not supplied or 0, the currently installed default allocator is used. The default format specification is:
|
explicit |
ball::RecordStringFormatter::RecordStringFormatter | ( | const char * | format, |
bslma::Allocator * | basicAllocator | ||
) |
Create a record formatter having the specified format
specification and a timestamp offset of 0. Optionally specify an allocator
(e.g., the address of a bslma::Allocator
object) to supply memory. If basicAllocator
is not supplied or 0, the currently installed default allocator is used.
|
explicit |
Create a record formatter having a default format specification and the specified timestamp offset
. Optionally specify an allocator
(e.g., the address of a bslma::Allocator
object) to supply memory; otherwise, the default allocator is used. The default format specification is:
publishInLocalTime
instead.
|
explicit |
Create a record formatter having a default format specification, and if the specified publishInLocalTime
flag is true
, format the timestamp of each logged record in the local time of the current task, and format the timestamp in UTC otherwise. Optionally specify an allocator
(e.g., the address of a bslma::Allocator
object) to supply memory; otherwise, the default allocator is used. The default format specification is:
Note that local time offsets are calculated for the timestamp of each formatted record and so track transitions into and out of Daylight Saving Time.
ball::RecordStringFormatter::RecordStringFormatter | ( | const char * | format, |
const bdlt::DatetimeInterval & | offset, | ||
const allocator_type & | allocator = allocator_type() |
||
) |
Create a record formatter having the specified format
specification and the specified timestamp offset
. Optionally specify an allocator
(e.g., the address of a bslma::Allocator
object) to supply memory; otherwise, the default allocator is used.
publishInLocalTime
instead. ball::RecordStringFormatter::RecordStringFormatter | ( | const char * | format, |
bool | publishInLocalTime, | ||
const allocator_type & | allocator = allocator_type() |
||
) |
Create a record formatter having the specified format
specification, and if the specified publishInLocalTime
flag is true
, format the timestamp of each log in the local time of the current task, and format the timestamp in UTC otherwise. Optionally specify an allocator
(e.g., the address of a bslma::Allocator
object) to supply memory; otherwise, the default allocator is used. Note that local time offsets are calculated for the timestamp of each formatted record and so track transitions into and out of Daylight Saving Time.
ball::RecordStringFormatter::RecordStringFormatter | ( | const RecordStringFormatter & | original, |
const allocator_type & | allocator = allocator_type() |
||
) |
Create a record 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.
|
default |
ball::RecordStringFormatter::BSLMF_NESTED_TRAIT_DECLARATION | ( | RecordStringFormatter | , |
bslma::UsesBslmaAllocator | |||
) |
void ball::RecordStringFormatter::disablePublishInLocalTime | ( | ) |
Disable adjust of the timestamp attribute of to the current local time by this file observer. This method has no effect if adjustment to the current local time is not enabled.
void ball::RecordStringFormatter::enablePublishInLocalTime | ( | ) |
Enable adjustment of the timestamp attribute to the current local time. This method has no effect if adjustment to the current local time is already enabled.
|
inline |
|
inline |
Return the allocator used by this object to supply memory. Note that if no allocator was supplied at construction the default allocator in effect at construction is used.
bool ball::RecordStringFormatter::isPublishInLocalTimeEnabled | ( | ) | const |
Return true
if this formatter adjusts the timestamp attribute to the current local time, and false
otherwise.
void ball::RecordStringFormatter::operator() | ( | bsl::ostream & | stream, |
const Record & | record | ||
) | const |
Format the specified record
according to the format specification of this record formatter and output the result to the specified stream
. The timestamp offset of this record formatter is added to each timestamp that is output to stream
.
RecordStringFormatter & ball::RecordStringFormatter::operator= | ( | const RecordStringFormatter & | rhs | ) |
Assign to this record formatter the value of the specified rhs
record formatter.
|
inline |
Set the format specification of this record formatter to the specified format
.
|
inline |
Set the timestamp offset of this record formatter to the specified offset
.
|
inline |
Return a reference to the non-modifiable timestamp offset of this record formatter.
|
static |
A simple standard record format that renders ball::Attribute
values in the formatted output. Note that this format is recommended over the default format, k_DEFAULT_FORMAT
, for most applications (the default format is currently maintained for backwards compatibility).
|
static |