BDE 4.39.x Production Release
Loading...
Searching...
No Matches
ball::RecordAttributes Class Reference

#include <ball_recordattributes.h>

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

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 bsl::string_view &fileName, int lineNumber, const bsl::string_view &category, int severity, const bsl::string_view &message, bslma::Allocator *basicAllocator=0)
 
 RecordAttributes (const bdlt::Datetime &timestamp, int processID, bsls::Types::Uint64 threadID, bsls::Types::Uint64 kernelThreadID, const bsl::string_view &fileName, int lineNumber, const bsl::string_view &category, int severity, const bsl::string_view &message, bslma::Allocator *basicAllocator=0)
 
 RecordAttributes (const RecordAttributes &original, bslma::Allocator *basicAllocator=0)
 
 ~RecordAttributes ()=default
 
RecordAttributesoperator= (const RecordAttributes &rhs)
 
void clearMessage ()
 
bdlsb::MemOutStreamBufmessageStreamBuf ()
 
bsl::ostream & messageStream ()
 
void setCategory (const bsl::string_view &category)
 
void setFileName (const bsl::string_view &fileName)
 
void setLineNumber (int lineNumber)
 
void setMessage (const bsl::string_view &message)
 
void setProcessID (int processID)
 
void setSeverity (int severity)
 
void setThreadID (bsls::Types::Uint64 threadID)
 
void setKernelThreadID (bsls::Types::Uint64 kernelThreadID)
 
void setTimestamp (const bdlt::Datetime &timestamp)
 
const char * category () const
 
const char * fileName () const
 
int lineNumber () const
 
const char * message () const
 
bslstl::StringRef messageRef () const
 
int processID () const
 
int severity () const
 
bsls::Types::Uint64 threadID () const
 
bsls::Types::Uint64 kernelThreadID () const
 
const bdlt::Datetimetimestamp () const
 
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 &)
 

Constructor & Destructor Documentation

◆ RecordAttributes() [1/4]

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/4]

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

Create a record attributes object having the specified timestamp, processID, threadID, kernelThreadId, 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.

◆ RecordAttributes() [3/4]

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

◆ RecordAttributes() [4/4]

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

Destroy this object.

Member Function Documentation

◆ BSLMF_NESTED_TRAIT_DECLARATION()

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

◆ category()

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

Return the category attribute of this record attributes object.

◆ 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

Return the filename attribute of this record attributes object.

◆ kernelThreadID()

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

Return the kernelThreadID attribute of this record attributes object.

◆ lineNumber()

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

Return the line number attribute of this record attributes object.

◆ message()

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

Return the message attribute of this record attributes object.

Note
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
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

Return the processID attribute of this record attributes object.

◆ setCategory()

void ball::RecordAttributes::setCategory ( const bsl::string_view category)
inline

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

◆ setFileName()

void ball::RecordAttributes::setFileName ( const bsl::string_view fileName)
inline

Set the filename attribute of this record attributes object to the specified fileName.

◆ setKernelThreadID()

void ball::RecordAttributes::setKernelThreadID ( bsls::Types::Uint64  kernelThreadID)
inline

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

◆ 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 bsl::string_view message)

Set the message attribute of this record attributes object to the specified 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

Return the severity attribute of this record attributes object.

◆ threadID()

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

Return the threadID attribute of this record attributes object.

◆ timestamp()

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

Return the timestamp attribute of this record attributes object.

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: