Loading...
Searching...
No Matches
casacore::LogMessage Class Reference
casa package (libcasa_casa) » Logging_module

More...

`#include <LogMessage.h>`

## Public Types

enum | Priority { DEBUGGING , DEBUG2 , DEBUG1 , NORMAL5 , NORMAL4 , NORMAL3 , NORMAL2 , NORMAL1 , NORMAL , WARN , SEVERE }
| An "importance" which is assigned to each LogMessage. More...

## Public Member Functions

| LogMessage (Priority priority=NORMAL)
| Create a message with the given priority and the current time, and an empty origin and message.
| LogMessage (const LogOrigin &sourceLocation, Priority priority=NORMAL)
| Create a message with the given location and priority, the current time and an empty message.
| LogMessage (const String &message, const LogOrigin &sourceLocation, Priority=NORMAL)
| Create a completely filled out LogMessage.
| LogMessage (const LogMessage &other)
| Make this LogMessage a copy of other.
LogMessage & | operator= (const LogMessage &other)
| ~LogMessage ()
const String & | message () const
| Get the message text.
LogMessage & | message (const String &message, Bool keepLastTime=False)
| Set the message text.
uInt | line () const
| Get and set the line number in the LogOrigin.
LogMessage & | line (uInt which)
LogMessage & | sourceLocation (const SourceLocation *where)
| Set the source location - usually this will be called with the macro WHERE.
const LogOrigin & | origin () const
| Get and set the origin of this LogMessage.
LogMessage & | origin (const LogOrigin &origin)
Priority | priority () const
| Get or change the priority of this LogMessage.
LogMessage & | priority (Priority which)
const Time & | messageTime () const
| Returns the time at which the message text was created.
LogMessage & | messageTime (const Time &theTime)
| Normally you should not manually set the time, however there may be rare circumstances where it is useful - for example if you have a single static message that you want to send out at various times.
String | toString () const
| Turn this entire LogMessage into a String.
String | toTermString () const

## Static Public Member Functions

static const String & | toString (Priority which)
| Map the given priority into a String - so, for example, it can be stored in a table.

## Private Member Functions

void | copy_other (const LogMessage &other)
| Provide common implementation for copy constructor and assignment operator.

## Private Attributes

String | message_p
LogOrigin | origin_p
Priority | priority_p
Time | time_p

## Detailed Description

Informational log messages with with time, priority, and origin.

### Intended use:

Public interface

### Review Status

Reviewed By:
  wbrouw
Date Reviewed:
  1996/08/21
Test programs:
  tLoging
Demo programs:
  dLogging

### Prerequisite

- LogOrigin

### Synopsis

A LogMessage is the unit of information in the Logging system. A LogMessage consists of an informational text (String) message tagged with the following:

- The time at which the message was generated ("computer" time, not high precision astronomical time).
- A priority - one of DEBUGGING, NORMAL, WARN, or SEVERE.
- A LogOrigin, containing the source code location where the message originated. It also contains the ObjectID if the originator was a distributed object. This is mostly of use in debugging.

### Example

void globalFunction(Int arg)
{
LogMessage logMessage(LogOrigin("globalFunction(Int arg)", WHERE));
..\.
logMessage.message("my message").line(__LINE__);
..\.
logMessage.message("my second message").line(__LINE__);
..\.
}
void MyClass::member(Int arg)
{
LogMessage logMessage(LogOrigin("myClass", "member(Int arg)", WHERE));
..\.
logMessage.message("my message").line(__LINE__);
..\.
}
WHERE
#define WHERE
Definition LogOrigin.h:212
casacore::LogMessage
Definition LogMessage.h:98
casacore::LogMessage::LogMessage
LogMessage(Priority priority=NORMAL)
Create a message with the given priority and the current time, and an empty origin and message.
casacore::LogOrigin
Definition LogOrigin.h:92
casacore::arg
LatticeExprNode arg(const LatticeExprNode &expr)
casacore::Int
int Int
Definition aipstype.h:48

A more complete example is available in the module file Logging.h.

### To Do

- Formerly we had a MessageType enum to go along with Priority. It was removed because the categories weren't sufficiently orthogonal. However the idea is probably sound and we might eventually want to put such a categorization back.
- toRecord() and fromRecord() functions will be needed when we integrate logging with Glish.

Definition at line 98 of file LogMessage.h.

## Member Enumeration Documentation

## Priority

enum casacore::LogMessage::Priority

An "importance" which is assigned to each LogMessage.

Enumerator
DEBUGGING | Low priority - primarily used for findding problems or tracing execution.
DEBUG2 |
DEBUG1 |
NORMAL5 | Most messages users see should have this priority. Use for "interesting" informational messages from normally executing software.
NORMAL4 |
NORMAL3 |
NORMAL2 |
NORMAL1 |
NORMAL |
WARN | Use messages of warning level to flag things that are unusual and might well be errors. Normally the software should proceed anyway rather than throw an exception.
SEVERE | Report on a problem detected by the software. Messages logged at this priority will often be followed by a thrown exception.

Definition at line 102 of file LogMessage.h.

## Constructor & Destructor Documentation

## LogMessage() [1/4]

casacore::LogMessage::LogMessage | ( | Priority | priority = NORMAL | ) |

Create a message with the given priority and the current time, and an empty origin and message.

References NORMAL, and priority().

Referenced by copy_other(), line(), LogMessage(), message(), messageTime(), operator=(), origin(), priority(), and sourceLocation().

## LogMessage() [2/4]

casacore::LogMessage::LogMessage | ( | const LogOrigin & | sourceLocation,
|  | Priority | priority = NORMAL )

Create a message with the given location and priority, the current time and an empty message.

This will likely be the most commonly used constructor when a given message is to be used several times in the same function.

References NORMAL, priority(), and sourceLocation().

## LogMessage() [3/4]

casacore::LogMessage::LogMessage | ( | const String & | message,
|  | const LogOrigin & | sourceLocation,
|  | Priority | = NORMAL )

Create a completely filled out LogMessage.

References message(), NORMAL, and sourceLocation().

## LogMessage() [4/4]

casacore::LogMessage::LogMessage | ( | const LogMessage & | other | ) |

Make this LogMessage a copy of other.

Note that the time is also copied over.

References LogMessage().

## ~LogMessage()

casacore::LogMessage::~LogMessage | ( |  | ) |

## Member Function Documentation

## copy_other()

void casacore::LogMessage::copy_other | ( | const LogMessage & | other | ) |

private

Provide common implementation for copy constructor and assignment operator.

References LogMessage().

## line() [1/2]

uInt casacore::LogMessage::line | ( |  | ) | const

Get and set the line number in the LogOrigin.

While in principle you can get and set this information through the origin() functions, in practice it is convenient to be able to directly get at the line number since it and the message text are usually the only things you change in a particular LogMessage object. Generally you will set the line number with the LINE macro.

## line() [2/2]

LogMessage & casacore::LogMessage::line | ( | uInt | which | ) |

References LogMessage().

## message() [1/2]

const String & casacore::LogMessage::message | ( |  | ) | const

Get the message text.

Referenced by LogMessage(), and message().

## message() [2/2]

LogMessage & casacore::LogMessage::message | ( | const String & | message,
|  | Bool | keepLastTime = False )

Set the message text.

If keepLastTime is True, the previous time will be used, otherwise the current time is used. This is intended for messages that come out at essentially identical times to aid in, e.g., Table selections.

References casacore::False, LogMessage(), and message().

## messageTime() [1/2]

const Time & casacore::LogMessage::messageTime | ( |  | ) | const

Returns the time at which the message text was created.

This time is presently "computer operating system" precision time, not high-precision astronomical time.

## messageTime() [2/2]

LogMessage & casacore::LogMessage::messageTime | ( | const Time & | theTime | ) |

Normally you should not manually set the time, however there may be rare circumstances where it is useful - for example if you have a single static message that you want to send out at various times.

References LogMessage().

## operator=()

LogMessage & casacore::LogMessage::operator= | ( | const LogMessage & | other | ) |

References LogMessage().

## origin() [1/2]

const LogOrigin & casacore::LogMessage::origin | ( |  | ) | const

Get and set the origin of this LogMessage.

If you only need the line number, use the line() or sourceOrigin() functions instead.

Referenced by origin().

## origin() [2/2]

LogMessage & casacore::LogMessage::origin | ( | const LogOrigin & | origin | ) |

References LogMessage(), and origin().

## priority() [1/2]

Priority casacore::LogMessage::priority | ( |  | ) | const

Get or change the priority of this LogMessage.

Referenced by LogMessage(), and LogMessage().

## priority() [2/2]

LogMessage & casacore::LogMessage::priority | ( | Priority | which | ) |

References LogMessage().

## sourceLocation()

LogMessage & casacore::LogMessage::sourceLocation | ( | const SourceLocation * | where | ) |

Set the source location - usually this will be called with the macro WHERE.

References LogMessage().

Referenced by LogMessage(), and LogMessage().

## toString() [1/2]

String casacore::LogMessage::toString | ( |  | ) | const

Turn this entire LogMessage into a String.

## toString() [2/2]

const String & casacore::LogMessage::toString | ( | Priority | which | ) |

static

Map the given priority into a String - so, for example, it can be stored in a table.

## toTermString()

String casacore::LogMessage::toTermString | ( |  | ) | const

## Member Data Documentation

## message_p

String casacore::LogMessage::message_p

private

Definition at line 205 of file LogMessage.h.

## origin_p

LogOrigin casacore::LogMessage::origin_p

private

Definition at line 206 of file LogMessage.h.

## priority_p

Priority casacore::LogMessage::priority_p

private

Definition at line 207 of file LogMessage.h.

## time_p

Time casacore::LogMessage::time_p

private

Definition at line 208 of file LogMessage.h.

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

- casa/Logging/LogMessage.h