4
// $Id: //poco/1.2/Foundation/include/Poco/Message.h#2 $
10
// Definition of the Message class.
12
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
15
// Permission is hereby granted, free of charge, to any person or organization
16
// obtaining a copy of the software and accompanying documentation covered by
17
// this license (the "Software") to use, reproduce, display, distribute,
18
// execute, and transmit the Software, and to prepare derivative works of the
19
// Software, and to permit third-parties to whom the Software is furnished to
20
// do so, all subject to the following:
22
// The copyright notices in the Software and this entire statement, including
23
// the above license grant, this restriction and the following disclaimer,
24
// must be included in all copies of the Software, in whole or in part, and
25
// all derivative works of the Software, unless such copies or derivative
26
// works are solely in the form of machine-executable object code generated by
27
// a source language processor.
29
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
32
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
33
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
34
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
35
// DEALINGS IN THE SOFTWARE.
39
#ifndef Foundation_Message_INCLUDED
40
#define Foundation_Message_INCLUDED
43
#include "Poco/Foundation.h"
44
#include "Poco/Timestamp.h"
51
class Foundation_API Message
52
/// This class represents a log message that is sent through a
53
/// chain of log channels.
55
/// A Message contains a priority denoting the severity of the
56
/// message, a source describing its origin, a text describing
57
/// its meaning, the time of its creation, and an identifier of
58
/// the process and thread that created the message.
60
/// A Message can also contain any number of named parameters
61
/// that contain additional information about the event that
62
/// caused the message.
67
PRIO_FATAL = 1, /// A fatal error. The application will most likely terminate. This is the highest priority.
68
PRIO_CRITICAL, /// A critical error. The application might not be able to continue running successfully.
69
PRIO_ERROR, /// An error. An operation did not complete successfully, but the application as a whole is not affected.
70
PRIO_WARNING, /// A warning. An operation completed with an unexpected result.
71
PRIO_NOTICE, /// A notice, which is an information with just a higher priority.
72
PRIO_INFORMATION, /// An informational message, usually denoting the successful completion of an operation.
73
PRIO_DEBUG, /// A debugging message.
74
PRIO_TRACE /// A tracing message. This is the lowest priority.
78
/// Creates an empty Message.
79
/// The thread and process ids are set.
81
Message(const std::string& source, const std::string& text, Priority prio);
82
/// Creates a Message with the given source, text and priority.
83
/// The thread and process ids are set.
85
Message(const Message& msg);
86
/// Creates a Message by copying another one.
88
Message(const Message& msg, const std::string& text);
89
/// Creates a Message by copying all but the text from another message.
92
/// Destroys the Message.
94
Message& operator = (const Message& msg);
95
/// Assignment operator.
97
void swap(Message& msg);
98
/// Swaps the message with another one.
100
void setSource(const std::string& src);
101
/// Sets the source of the message.
103
const std::string& getSource() const;
104
/// Returns the source of the message.
106
void setText(const std::string& text);
107
/// Sets the text of the message.
109
const std::string& getText() const;
110
/// Returns the text of the message.
112
void setPriority(Priority prio);
113
/// Sets the priority of the message.
115
Priority getPriority() const;
116
/// Returns the priority of the message.
118
void setTime(const Timestamp& time);
119
/// Sets the time of the message.
121
const Timestamp& getTime() const;
122
/// Returns the time of the message.
124
void setThread(const std::string& thread);
125
/// Sets the thread identifier for the message.
127
const std::string& getThread() const;
128
/// Returns the thread identifier for the message.
130
void setTid(long pid);
131
/// Sets the numeric thread identifier for the message.
134
/// Returns the numeric thread identifier for the message.
136
void setPid(long pid);
137
/// Sets the process identifier for the message.
140
/// Returns the process identifier for the message.
142
const std::string& operator [] (const std::string& param) const;
143
/// Returns a const reference to the value of the parameter
144
/// with the given name. Throws a NotFoundException if the
145
/// parameter does not exist.
147
std::string& operator [] (const std::string& param);
148
/// Returns a reference to the value of the parameter with the
149
/// given name. This can be used to set the parameter's value.
150
/// If the parameter does not exist, it is created with an
151
/// empty string value.
155
typedef std::map<std::string, std::string> StringMap;
172
inline const std::string& Message::getSource() const
178
inline const std::string& Message::getText() const
184
inline Message::Priority Message::getPriority() const
190
inline const std::string& Message::getThread() const
196
inline long Message::getTid() const
202
inline long Message::getPid() const
208
inline void swap(Message& m1, Message& m2)
217
#endif // Foundation_Message_INCLUDED