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)
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)
Review Status
- Reviewed By:
- wbrouw
- Date Reviewed:
- 1996/08/21
- Programs:
- Demos:
- Tests:
Prerequisite
- ObjectID if you are interested in
logging from Distributed Objects (don't worry if you don't know what
that means - in that case ignore it!).
Etymology
Log[message] Origin[ation point].
Synopsis
The LogOriging class is used to record the location at which a
LogMessage originates. It consists of:
- A class name, which is blank in the case of a global function.
- A function name - global or member. You should "cut and paste" not only
the function name, but also the arguments (but not the return type) to
ensure that the function name is unique in the face of overloading.
- A source file name, usually filled in with the WHERE
predefined macro.
- A line number, usually filled in with the __LINE__ or
WHERE macros.
- An ObjectID if the log message comes
from a distributed object (if you don't know what this means,
you don't need to worry about it).
- Eventually we may want to canonicalize the path in the filename.
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
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.
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.
Returns class::function for a member function, or
::function for a global function.
Turn the entire origin into a String.
Turns the entire origin except for the ObjectID into a String. The
ObjectID can be turned into a string vie ObjectID::toString.
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.
Interface
- ostream &operator<<(ostream &os, const LogOrigin &origin)
Write a LogOrigin as a string to an ostream. Merely calls
LogOrigin::toString()
Member Description
ostream &operator<<(ostream &os, const LogOrigin &origin)
Interface
The user should only use the WHERE macro.
Member Description