Vidalia
0.2.21
Main Page
Namespaces
Classes
Files
File List
File Members
src
torcontrol
LogEvent.cpp
Go to the documentation of this file.
1
/*
2
** This file is part of Vidalia, and is subject to the license terms in the
3
** LICENSE file, found in the top level directory of this distribution. If
4
** you did not receive the LICENSE file with this file, you may obtain it
5
** from the Vidalia source package distributed by the Vidalia Project at
6
** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
7
** including this file, may be copied, modified, propagated, or distributed
8
** except according to the terms described in the LICENSE file.
9
*/
10
11
/*
12
** \file LogEvent.cpp
13
** \brief Event dispatched containing a log message from Tor
14
*/
15
16
#include "
LogEvent.h
"
17
#include "eventtype.h"
18
19
20
/** Default constructor */
21
LogEvent::LogEvent
(
Severity
severity, QString message)
22
: QEvent((QEvent::Type)CustomEventType::
LogEvent
)
23
{
24
_severity
=
severity
;
25
_message
= message.trimmed();
26
}
27
28
/** Converts a string description of a severity to its enum value */
29
LogEvent::Severity
30
LogEvent::toSeverity
(QString strSeverity)
31
{
32
Severity
s;
33
strSeverity = strSeverity.toUpper();
34
if
(strSeverity ==
"DEBUG"
) {
35
s =
Debug
;
36
}
else
if
(strSeverity ==
"INFO"
) {
37
s =
Info
;
38
}
else
if
(strSeverity ==
"NOTICE"
) {
39
s =
Notice
;
40
}
else
if
(strSeverity ==
"WARN"
) {
41
s =
Warn
;
42
}
else
if
(strSeverity ==
"ERR"
|| strSeverity ==
"ERROR"
) {
43
s =
Error
;
44
}
else
{
45
s =
Unknown
;
46
}
47
return
s;
48
}
49
50
/** Converts a Severity enum value to a string description */
51
QString
52
LogEvent::severityToString
(
Severity
s)
53
{
54
QString str;
55
switch
(s) {
56
case
Debug
: str = tr(
"Debug"
);
break
;
57
case
Info
: str = tr(
"Info"
);
break
;
58
case
Notice
: str = tr(
"Notice"
);
break
;
59
case
Warn
: str = tr(
"Warning"
);
break
;
60
case
Error
: str = tr(
"Error"
);
break
;
61
default
: str = tr(
"Unknown"
);
break
;
62
}
63
return
str;
64
}
65
66
/** Returns the severity of this log event */
67
LogEvent::Severity
68
LogEvent::severity
()
const
69
{
70
return
_severity
;
71
}
72
73
/** Returns the message for this log event */
74
QString
75
LogEvent::message
()
const
76
{
77
return
_message
;
78
}
79
Generated on Thu Dec 6 2012 04:33:16 for Vidalia by
1.8.2