BDE 4.14.0 Production release
Loading...
Searching...
No Matches
ball::RecordStringFormatter Class Reference

#include <ball_recordstringformatter.h>

Public Types

typedef bsl::allocator< char > allocator_type
 

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (RecordStringFormatter, bslma::UsesBslmaAllocator)
 
 RecordStringFormatter (const allocator_type &allocator=allocator_type())
 
 RecordStringFormatter (bslma::Allocator *basicallocator)
 
 RecordStringFormatter (const char *format, const allocator_type &allocator=allocator_type())
 
 RecordStringFormatter (const char *format, bslma::Allocator *basicAllocator)
 
 RecordStringFormatter (const bdlt::DatetimeInterval &offset, const allocator_type &allocator=allocator_type())
 
 RecordStringFormatter (bool publishInLocalTime, const allocator_type &allocator=allocator_type())
 
 RecordStringFormatter (const char *format, const bdlt::DatetimeInterval &offset, const allocator_type &allocator=allocator_type())
 
 RecordStringFormatter (const char *format, bool publishInLocalTime, const allocator_type &allocator=allocator_type())
 
 RecordStringFormatter (const RecordStringFormatter &original, const allocator_type &allocator=allocator_type())
 
 ~RecordStringFormatter ()=default
 Destroy this object.
 
RecordStringFormatteroperator= (const RecordStringFormatter &rhs)
 
void disablePublishInLocalTime ()
 
void enablePublishInLocalTime ()
 
void setFormat (const char *format)
 
void setTimestampOffset (const bdlt::DatetimeInterval &offset)
 
void operator() (bsl::ostream &stream, const Record &record) const
 
const char * format () const
 Return the format specification of this record formatter.
 
bool isPublishInLocalTimeEnabled () const
 
const bdlt::DatetimeIntervaltimestampOffset () const
 
allocator_type get_allocator () const
 

Static Public Attributes

static const char * k_DEFAULT_FORMAT
 The default log format specification used by RecordStringFormatter.
 
static const char * k_BASIC_ATTRIBUTE_FORMAT
 

Detailed Description

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.

See ball_recordstringformatter

Member Typedef Documentation

◆ allocator_type

Constructor & Destructor Documentation

◆ RecordStringFormatter() [1/9]

ball::RecordStringFormatter::RecordStringFormatter ( const allocator_type allocator = allocator_type())
explicit

◆ RecordStringFormatter() [2/9]

ball::RecordStringFormatter::RecordStringFormatter ( bslma::Allocator basicallocator)
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:

"\n%d %p:%t %s %f:%l %c %m %u\n"

◆ RecordStringFormatter() [3/9]

ball::RecordStringFormatter::RecordStringFormatter ( const char *  format,
const allocator_type allocator = allocator_type() 
)
explicit

◆ RecordStringFormatter() [4/9]

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.

◆ RecordStringFormatter() [5/9]

ball::RecordStringFormatter::RecordStringFormatter ( const bdlt::DatetimeInterval offset,
const allocator_type allocator = allocator_type() 
)
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:

"\n%d %p:%t %s %f:%l %c %m %u\n"
Deprecated:
Use a constructor taking publishInLocalTime instead.

◆ RecordStringFormatter() [6/9]

ball::RecordStringFormatter::RecordStringFormatter ( bool  publishInLocalTime,
const allocator_type allocator = allocator_type() 
)
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:

"\n%d %p:%t %s %f:%l %c %m %u\n"

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.

◆ RecordStringFormatter() [7/9]

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.

Deprecated:
Use a constructor taking publishInLocalTime instead.

◆ RecordStringFormatter() [8/9]

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.

◆ RecordStringFormatter() [9/9]

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.

◆ ~RecordStringFormatter()

ball::RecordStringFormatter::~RecordStringFormatter ( )
default

Member Function Documentation

◆ BSLMF_NESTED_TRAIT_DECLARATION()

ball::RecordStringFormatter::BSLMF_NESTED_TRAIT_DECLARATION ( RecordStringFormatter  ,
bslma::UsesBslmaAllocator   
)

◆ disablePublishInLocalTime()

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.

◆ enablePublishInLocalTime()

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.

◆ format()

const char * ball::RecordStringFormatter::format ( ) const
inline

◆ get_allocator()

RecordStringFormatter::allocator_type ball::RecordStringFormatter::get_allocator ( ) const
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.

◆ isPublishInLocalTimeEnabled()

bool ball::RecordStringFormatter::isPublishInLocalTimeEnabled ( ) const

Return true if this formatter adjusts the timestamp attribute to the current local time, and false otherwise.

◆ operator()()

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.

◆ operator=()

RecordStringFormatter & ball::RecordStringFormatter::operator= ( const RecordStringFormatter rhs)

Assign to this record formatter the value of the specified rhs record formatter.

◆ setFormat()

void ball::RecordStringFormatter::setFormat ( const char *  format)
inline

Set the format specification of this record formatter to the specified format.

◆ setTimestampOffset()

void ball::RecordStringFormatter::setTimestampOffset ( const bdlt::DatetimeInterval offset)
inline

Set the timestamp offset of this record formatter to the specified offset.

Deprecated:
Use enablePublishInLocalTime instead.

◆ timestampOffset()

const bdlt::DatetimeInterval & ball::RecordStringFormatter::timestampOffset ( ) const
inline

Return a reference to the non-modifiable timestamp offset of this record formatter.

Deprecated:
Use isPublishInLocalTimeEnabled instead.

Member Data Documentation

◆ k_BASIC_ATTRIBUTE_FORMAT

const char* ball::RecordStringFormatter::k_BASIC_ATTRIBUTE_FORMAT
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).

◆ k_DEFAULT_FORMAT

const char* ball::RecordStringFormatter::k_DEFAULT_FORMAT
static

The documentation for this class was generated from the following file: