Quick Links:

bal | bbl | bdl | bsl

Public Types | Public Member Functions | Static Public Attributes

ball::RecordStringFormatter Class Reference

#include <ball_recordstringformatter.h>

List of all members.

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 ()
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
bool isPublishInLocalTimeEnabled () const
const bdlt::DatetimeIntervaltimestampOffset () const
allocator_type get_allocator () const

Static Public Attributes

static const char * k_DEFAULT_FORMAT
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 Component ball_recordstringformatter


Member Typedef Documentation


Constructor & Destructor Documentation

ball::RecordStringFormatter::RecordStringFormatter ( const allocator_type allocator = allocator_type()  )  [explicit]
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"
ball::RecordStringFormatter::RecordStringFormatter ( const char *  format,
const allocator_type allocator = allocator_type() 
) [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.

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.

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.

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.

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.

ball::RecordStringFormatter::~RecordStringFormatter (  ) 

Destroy this object.


Member Function Documentation

ball::RecordStringFormatter::BSLMF_NESTED_TRAIT_DECLARATION ( RecordStringFormatter  ,
bslma::UsesBslmaAllocator   
)
RecordStringFormatter& ball::RecordStringFormatter::operator= ( const RecordStringFormatter rhs  ) 

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

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.

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

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

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

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

DEPRECATED: Use enablePublishInLocalTime instead.

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.

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

Return the format specification of this record formatter.

bool ball::RecordStringFormatter::isPublishInLocalTimeEnabled (  )  const

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

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

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

DEPRECATED: Use isPublishInLocalTimeEnabled instead.

allocator_type ball::RecordStringFormatter::get_allocator (  )  const

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.


Member Data Documentation


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