Class Poco::Message
Author: Applied Informatics Software Engineering GmbH and Contributors
Date: 2009-11-24

# Poco

# class Message

Library: Foundation
Package: Logging
Header: Poco/Message.h

## Description

This class represents a log message that is sent through a chain of log channels.

A Message contains a priority denoting the severity of the message, a source describing its origin, a text describing its meaning, the time of its creation, and an identifier of the process and thread that created the message.

A Message can also contain any number of named parameters that contain additional information about the event that caused the message.

## Member Summary

Member Functions: getPid, getPriority, getSource, getText, getThread, getTid, getTime, init, operator, operator =, setPid, setPriority, setSource, setText, setThread, setTid, setTime, swap

## Types

### StringMap

typedef std::map < std::string, std::string > StringMap;

## Enumerations

### Priority

PRIO_FATAL = 1

A fatal error. The application will most likely terminate. This is the highest priority.

PRIO_CRITICAL

A critical error. The application might not be able to continue running successfully.

PRIO_ERROR

An error. An operation did not complete successfully, but the application as a whole is not affected.

PRIO_WARNING

A warning. An operation completed with an unexpected result.

PRIO_NOTICE

A notice, which is an information with just a higher priority.

PRIO_INFORMATION

An informational message, usually denoting the successful completion of an operation.

PRIO_DEBUG

A debugging message.

PRIO_TRACE

A tracing message. This is the lowest priority.

## Constructors

### Message

Message();

Creates an empty Message. The thread and process ids are set.

### Message

Message(
const Message & msg
);

Creates a Message by copying another one.

### Message

Message(
const Message & msg,
const std::string & text
);

Creates a Message by copying all but the text from another message.

### Message

Message(
const std::string & source,
const std::string & text,
Priority prio
);

Creates a Message with the given source, text and priority. The thread and process ids are set.

## Destructor

### ~Message

~Message();

Destroys the Message.

## Member Functions

### getPid

long getPid() const;

Returns the process identifier for the message.

### getPriority

Priority getPriority() const;

Returns the priority of the message.

### getSource

const std::string & getSource() const;

Returns the source of the message.

### getText

const std::string & getText() const;

Returns the text of the message.

### getThread

const std::string & getThread() const;

Returns the thread identifier for the message.

### getTid

long getTid() const;

Returns the numeric thread identifier for the message.

### getTime

const Timestamp & getTime() const;

Returns the time of the message.

### operator

const std::string & operator[] (
const std::string & param
) const;

Returns a const reference to the value of the parameter with the given name. Throws a NotFoundException if the parameter does not exist.

### operator

std::string & operator[] (
const std::string & param
);

Returns a reference to the value of the parameter with the given name. This can be used to set the parameter's value. If the parameter does not exist, it is created with an empty string value.

### operator =

Message & operator = (
const Message & msg
);

Assignment operator.

### setPid

void setPid(
long pid
);

Sets the process identifier for the message.

### setPriority

void setPriority(
Priority prio
);

Sets the priority of the message.

### setSource

void setSource(
const std::string & src
);

Sets the source of the message.

### setText

void setText(
const std::string & text
);

Sets the text of the message.

### setThread

void setThread(
const std::string & thread
);

Sets the thread identifier for the message.

### setTid

void setTid(
long pid
);

Sets the numeric thread identifier for the message.

### setTime

void setTime(
const Timestamp & time
);

Sets the time of the message.

### swap

void swap(
Message & msg
);

Swaps the message with another one.

### init

void init();