LogOrigin.h

Classes

LogOrigin -- LogOrigin: The source code location of the originator of a LogMessage. (full description)
Global Functions -- Write a LogOrigin to an ostream. (full description)
Global Functions -- Helper struct to get the source line. (full description)

class LogOrigin

Interface

Public Members
LogOrigin()
LogOrigin(const String &globalFunctionName, const SourceLocation *where = 0)
LogOrigin(const String &className, const String &memberFuncName, const SourceLocation *where = 0)
LogOrigin(const String &className, const String &memberFuncName, const ObjectID &id, const SourceLocation *where = 0)
LogOrigin(const LogOrigin &other)
LogOrigin &operator=(const LogOrigin &other)
~LogOrigin()
const String &functionName() const
LogOrigin &functionName(const String &funcName)
const String &className() const
LogOrigin &className(const String &className)
const ObjectID &objectID() const
LogOrigin &objectID(const ObjectID &id)
uInt line() const
LogOrigin &line(uInt which)
const String &fileName() const
LogOrigin &fileName(const String &fileName)
LogOrigin &sourceLocation(const SourceLocation *where)
String fullName() const
String toString() const
String location() const
Bool isUnset() const
Private Members
void copy_other(const LogOrigin &other)

Description

Review Status

Reviewed By:
wbrouw
Date Reviewed:
1996/08/21
Programs:
Demos:
Tests:

Prerequisite

Etymology

Log[message] Origin[ation point].

Synopsis

The LogOriging class is used to record the location at which a LogMessage originates. It consists of:

Example

See the examples for LogMessage and in Logging.h.

Motivation

It can be very useful for debugging if you know where a message is coming from.

To Do

Member Description

LogOrigin()

The default constructor sets a null class name, function name, object id, source file name, and sets the line number to zero.

LogOrigin(const String &globalFunctionName, const SourceLocation *where = 0)

Use this constructor if the log message origination is from a global function. Normally where is provided using the WHERE macro.

LogOrigin(const String &className, const String &memberFuncName, const SourceLocation *where = 0)

Use this constructor if the log message origination is from a class member function. Normally where is provided using the WHERE macro.

LogOrigin(const String &className, const String &memberFuncName, const ObjectID &id, const SourceLocation *where = 0)

Use this constructor if the log message origination is from a distributed object (don't worry if you don't know what this means). Normally where is provided using the WHERE macro.

LogOrigin(const LogOrigin &other)
LogOrigin &operator=(const LogOrigin &other)

Make this LogOrigin a copy of other.

~LogOrigin()

const String &functionName() const
LogOrigin &functionName(const String &funcName)
const String &className() const
LogOrigin &className(const String &className)
const ObjectID &objectID() const
LogOrigin &objectID(const ObjectID &id)
uInt line() const
LogOrigin &line(uInt which)
const String &fileName() const
LogOrigin &fileName(const String &fileName)

Get or set the corresponding element of the source location. Note that the "set" functions can be strung together:

    LogOrigin where;
    ...
    where.function("anotherFunc").line(__LINE__);
    

LogOrigin &sourceLocation(const SourceLocation *where)

Set the file name and line number at the same time. Normally where will be defined with the WHERE macro.

String fullName() const

Returns class::function for a member function, or ::function for a global function.

String toString() const

Turn the entire origin into a String.

String location() const

Turns the entire origin except for the ObjectID into a String. The ObjectID can be turned into a string vie ObjectID::toString.

Bool isUnset() const

Return true if the line number and file name are not set.

void copy_other(const LogOrigin &other)

Provide common implementation for copy constructor and assignment operator.


Write a LogOrigin to an ostream. (source)

Interface

ostream &operator<<(ostream &os, const LogOrigin &origin)

Description

Write a LogOrigin as a string to an ostream. Merely calls LogOrigin::toString()

Member Description

ostream &operator<<(ostream &os, const LogOrigin &origin)


Helper struct to get the source line. (source)

Interface

Description

The user should only use the WHERE macro.

Member Description