Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Member Functions | Protected Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends
Arc::LogMessage Class Reference

A class for log messages. More...

#include <Logger.h>

Collaboration diagram for Arc::LogMessage:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 LogMessage (LogLevel level, const IString &message)
 Creates a LogMessage with the specified level and message text.
 LogMessage (LogLevel level, const IString &message, const std::string &identifier)
 Creates a LogMessage with the specified attributes.
LogLevel getLevel () const
 Returns the level of the LogMessage.

Protected Member Functions

void setIdentifier (std::string identifier)
 Sets the identifier of the LogMessage.

Private Member Functions

void setDomain (std::string domain)
 Sets the domain of the LogMessage.

Static Private Member Functions

static std::string getDefaultIdentifier ()
 Composes a default identifier.

Private Attributes

std::string time
 The time when the LogMessage was created.
LogLevel level
 The level (severity) of the LogMessage.
std::string domain
 The domain (origin) of the LogMessage.
std::string identifier
 An identifier that may be used for filtering.
IString message
 The message text.

Friends

class Logger
 The Logger class is a friend.
std::ostream & operator<< (std::ostream &os, const LogMessage &message)
 Printing of LogMessages to ostreams.

Detailed Description

A class for log messages.

This class is used to represent log messages internally. It contains the time the message was created, its level, from which domain it was sent, an identifier and the message text itself.

Definition at line 86 of file Logger.h.


Constructor & Destructor Documentation

Arc::LogMessage::LogMessage ( LogLevel  level,
const IString message 
)

Creates a LogMessage with the specified level and message text.

This constructor creates a LogMessage with the specified level and message text. The time is set automatically, the domain is set by the Logger to which the LogMessage is sent and the identifier is composed from the process ID and the address of the Thread object corresponding to the calling thread.

Parameters:
levelThe level of the LogMessage.
messageThe message text.

Definition at line 117 of file Logger.cpp.

Arc::LogMessage::LogMessage ( LogLevel  level,
const IString message,
const std::string &  identifier 
)

Creates a LogMessage with the specified attributes.

This constructor creates a LogMessage with the specified level, message text and identifier. The time is set automatically and the domain is set by the Logger to which the LogMessage is sent.

Parameters:
levelThe level of the LogMessage.
messageThe message text.
identThe identifier of the LogMessage.

Definition at line 125 of file Logger.cpp.


Member Function Documentation

std::string Arc::LogMessage::getDefaultIdentifier ( ) [static, private]

Composes a default identifier.

This method composes a default identifier by combining the the process ID and the address of the Thread object corresponding to the calling thread.

Returns:
A default identifier.

Definition at line 142 of file Logger.cpp.

                                             {
    std::ostringstream sout;
#ifdef HAVE_GETPID
    sout << getpid() << "/"
         << (unsigned long int)(void*)Glib::Thread::self();
#else
    sout << (unsigned long int)(void*)Glib::Thread::self();
#endif
    return sout.str();
  }

Returns the level of the LogMessage.

Returns the level of the LogMessage.

Returns:
The level of the LogMessage.

Definition at line 134 of file Logger.cpp.

                                      {
    return level;
  }

Here is the caller graph for this function:

void Arc::LogMessage::setDomain ( std::string  domain) [private]

Sets the domain of the LogMessage.

This method sets the domain (origin) of the LogMessage. It is called by the Logger to which the LogMessage is sent.

Parameters:
domainThe domain.

Definition at line 153 of file Logger.cpp.

                                             {
    this->domain = domain;
  }

Here is the caller graph for this function:

void Arc::LogMessage::setIdentifier ( std::string  identifier) [protected]

Sets the identifier of the LogMessage.

The purpose of this method is to allow subclasses (in case there are any) to set the identifier of a LogMessage.

Parameters:
Theidentifier.

Definition at line 138 of file Logger.cpp.

                                                     {
    this->identifier = identifier;
  }

Friends And Related Function Documentation

friend class Logger [friend]

The Logger class is a friend.

The Logger class must have some privileges (e.g. ability to call the setDomain() method), therefore it is a friend.

Definition at line 172 of file Logger.h.

std::ostream& operator<< ( std::ostream &  os,
const LogMessage message 
) [friend]

Printing of LogMessages to ostreams.

Output operator so that LogMessages can be printed conveniently by LogDestinations.

Definition at line 164 of file Logger.cpp.

                                                                    {
    switch (os.iword(formatindex)) {
    case LongFormat:
      os << "[" << message.time << "] "
         << "[" << message.domain << "] "
         << "[" << message.level << "] "
         << "[" << message.identifier << "] "
         << message.message;
      break;
    case ShortFormat:
      os << message.level << ": " << message.message;
      break;
    }
    return os;
  }

Member Data Documentation

std::string Arc::LogMessage::domain [private]

The domain (origin) of the LogMessage.

Definition at line 153 of file Logger.h.

std::string Arc::LogMessage::identifier [private]

An identifier that may be used for filtering.

Definition at line 156 of file Logger.h.

The level (severity) of the LogMessage.

Definition at line 150 of file Logger.h.

The message text.

Definition at line 159 of file Logger.h.

std::string Arc::LogMessage::time [private]

The time when the LogMessage was created.

Definition at line 147 of file Logger.h.


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