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

#include <ball_recordattributes.h>

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (RecordAttributes, bslma::UsesBslmaAllocator)
 
 RecordAttributes (bslma::Allocator *basicAllocator=0)
 
 RecordAttributes (const bdlt::Datetime &timestamp, int processID, bsls::Types::Uint64 threadID, const char *fileName, int lineNumber, const char *category, int severity, const char *message, bslma::Allocator *basicAllocator=0)
 
 RecordAttributes (const RecordAttributes &original, bslma::Allocator *basicAllocator=0)
 
 ~RecordAttributes ()=default
 Destroy this object.
 
RecordAttributesoperator= (const RecordAttributes &rhs)
 
void clearMessage ()
 
bdlsb::MemOutStreamBufmessageStreamBuf ()
 
bsl::ostream & messageStream ()
 
void setCategory (const char *category)
 
void setFileName (const char *fileName)
 
void setLineNumber (int lineNumber)
 
void setMessage (const char *message)
 
void setProcessID (int processID)
 
void setSeverity (int severity)
 
void setThreadID (bsls::Types::Uint64 threadID)
 
void setTimestamp (const bdlt::Datetime &timestamp)
 
const char * category () const
 Return the category attribute of this record attributes object.
 
const char * fileName () const
 Return the filename attribute of this record attributes object.
 
int lineNumber () const
 Return the line number attribute of this record attributes object.
 
const char * message () const
 
bslstl::StringRef messageRef () const
 
int processID () const
 Return the processID attribute of this record attributes object.
 
int severity () const
 Return the severity attribute of this record attributes object.
 
bsls::Types::Uint64 threadID () const
 Return the threadID attribute of this record attributes object.
 
const bdlt::Datetimetimestamp () const
 Return the timestamp attribute of this record attributes object.
 
const bdlsb::MemOutStreamBufmessageStreamBuf () const
 
const bsl::ostream & messageStream () const
 
bsl::ostream & print (bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
 

Friends

bool operator== (const RecordAttributes &, const RecordAttributes &)
 

Detailed Description

This class provides a container for a fixed set of attributes appropriate for logging. For each attribute in this class (e.g., category), there is an accessor for obtaining the attribute's value (the category accessor) and a manipulator for changing the attribute's value (the setCategory manipulator).

Additionally, this class supports a complete set of value semantic operations, including copy construction, assignment and equality comparison, and ostream printing. A precise operational definition of when two instances have the same value can be found in the description of operator== for the class. This class is exception neutral with no guarantee of rollback: If an exception is thrown during the invocation of a method on a pre-existing instance, the object is left in a valid state, but its value is undefined. In no event is memory leaked. Finally, aliasing (e.g., using all or part of an object as both source and destination) is supported in all cases.

See ball_recordattributes

Constructor & Destructor Documentation

◆ RecordAttributes() [1/3]

ball::RecordAttributes::RecordAttributes ( bslma::Allocator basicAllocator = 0)
explicit

Create a record attributes object with all attributes having default values. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

◆ RecordAttributes() [2/3]

ball::RecordAttributes::RecordAttributes ( const bdlt::Datetime timestamp,
int  processID,
bsls::Types::Uint64  threadID,
const char *  fileName,
int  lineNumber,
const char *  category,
int  severity,
const char *  message,
bslma::Allocator basicAllocator = 0 
)

Create a record attributes object having the specified timestamp, processID, threadID, fileName, lineNumber, category, severity and message values, respectively. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. The behavior is undefined if any const char * argument is null.

◆ RecordAttributes() [3/3]

ball::RecordAttributes::RecordAttributes ( const RecordAttributes original,
bslma::Allocator basicAllocator = 0 
)

Create a record attributes object having the value of the specified original record attributes object. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

◆ ~RecordAttributes()

ball::RecordAttributes::~RecordAttributes ( )
default

Member Function Documentation

◆ BSLMF_NESTED_TRAIT_DECLARATION()

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

◆ category()

const char * ball::RecordAttributes::category ( ) const
inline

◆ clearMessage()

void ball::RecordAttributes::clearMessage ( )
inline

Set the message attribute of this record attributes object to the empty string. Resets the objects returned by the messageStreamBuf and messageStream methods.

◆ fileName()

const char * ball::RecordAttributes::fileName ( ) const
inline

◆ lineNumber()

int ball::RecordAttributes::lineNumber ( ) const
inline

◆ message()

const char * ball::RecordAttributes::message ( ) const

Return the message attribute of this record attributes object. Note that this method will return a truncated message if it contains embedded null ('\0') characters; see messageRef for an alternative to this method. Warning: This method is not const thread-safe, and cannot be safely called concurrently. It may modify the stream buffer returned by messageStreamBuf.

Deprecated:
Use messageRef instead.

◆ messageRef()

bslstl::StringRef ball::RecordAttributes::messageRef ( ) const

Return a string reference providing non-modifiable access to the message attribute of this record attributes object. Note that the returned string reference is not null-terminated, and may contain null ('\0') characters.

◆ messageStream() [1/2]

bsl::ostream & ball::RecordAttributes::messageStream ( )
inline

Return a reference to the modifiable stream associated with the message attribute of this record attributes object.

◆ messageStream() [2/2]

const bsl::ostream & ball::RecordAttributes::messageStream ( ) const
inline

Return a reference to the non-modifiable stream associated with the message attribute of this record attributes object.

◆ messageStreamBuf() [1/2]

bdlsb::MemOutStreamBuf & ball::RecordAttributes::messageStreamBuf ( )
inline

Return a reference to the modifiable stream buffer associated with the message attribute of this record attributes object.

◆ messageStreamBuf() [2/2]

const bdlsb::MemOutStreamBuf & ball::RecordAttributes::messageStreamBuf ( ) const
inline

Return a reference to the non-modifiable stream buffer associated with the message attribute of this record attributes object.

◆ operator=()

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

Assign to this record attributes object the value of the specified rhs record attributes object. Resets the objects returned by the messageStreamBuf and messageStream methods.

◆ print()

bsl::ostream & ball::RecordAttributes::print ( bsl::ostream &  stream,
int  level = 0,
int  spacesPerLevel = 4 
) const

Format this object to the specified output stream at the optionally specified indentation level and return a reference to the modifiable stream. If level is specified, optionally specify spacesPerLevel, the number of spaces per indentation level for this and all of its nested objects. Each line is indented by the absolute value of level * spacesPerLevel. If level is negative, suppress indentation of the first line. If spacesPerLevel is negative, suppress line breaks and format the entire output on one line. If stream is initially invalid, this operation has no effect.

◆ processID()

int ball::RecordAttributes::processID ( ) const
inline

◆ setCategory()

void ball::RecordAttributes::setCategory ( const char *  category)
inline

Set the category attribute of this record attributes object to the specified (non-null) category.

◆ setFileName()

void ball::RecordAttributes::setFileName ( const char *  fileName)
inline

Set the filename attribute of this record attributes object to the specified (non-null) fileName.

◆ setLineNumber()

void ball::RecordAttributes::setLineNumber ( int  lineNumber)
inline

Set the line number attribute of this record attributes object to the specified lineNumber.

◆ setMessage()

void ball::RecordAttributes::setMessage ( const char *  message)

Set the message attribute of this record attributes object to the specified (non-null) message. Resets the objects returned by the messageStreamBuf and messageStream methods.

◆ setProcessID()

void ball::RecordAttributes::setProcessID ( int  processID)
inline

Set the processID attribute of this record attributes object to the specified processID.

◆ setSeverity()

void ball::RecordAttributes::setSeverity ( int  severity)
inline

Set the severity attribute of this record attributes object to the specified severity.

◆ setThreadID()

void ball::RecordAttributes::setThreadID ( bsls::Types::Uint64  threadID)
inline

Set the threadID attribute of this record attributes object to the specified threadID.

◆ setTimestamp()

void ball::RecordAttributes::setTimestamp ( const bdlt::Datetime timestamp)
inline

Set the timestamp attribute of this record attributes object to the specified timestamp.

◆ severity()

int ball::RecordAttributes::severity ( ) const
inline

◆ threadID()

bsls::Types::Uint64 ball::RecordAttributes::threadID ( ) const
inline

◆ timestamp()

const bdlt::Datetime & ball::RecordAttributes::timestamp ( ) const
inline

Friends And Related Symbol Documentation

◆ operator==

bool operator== ( const RecordAttributes ,
const RecordAttributes  
)
friend

Return true if the specified lhs and rhs record attributes objects have the same value, and false otherwise. Two record attributes objects have the same value if each respective pair of attributes have the same value.


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