Vidalia 0.3.1
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 */
21LogEvent::LogEvent(Severity severity, QString message)
22: QEvent((QEvent::Type)CustomEventType::LogEvent)
23{
25 _message = message.trimmed();
26}
27
28/** Converts a string description of a severity to its enum value */
30LogEvent::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 */
51QString
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 */
69{
70 return _severity;
71}
72
73/** Returns the message for this log event */
74QString
76{
77 return _message;
78}
79
LogEvent(Severity severity, QString message)
Definition: LogEvent.cpp:21
static QString severityToString(Severity severity)
Definition: LogEvent.cpp:52
static Severity toSeverity(QString strSeverity)
Definition: LogEvent.cpp:30
@ Notice
Definition: LogEvent.h:34
@ Error
Definition: LogEvent.h:36
@ Info
Definition: LogEvent.h:33
@ Debug
Definition: LogEvent.h:32
@ Unknown
Definition: LogEvent.h:31
@ Warn
Definition: LogEvent.h:35
QString _message
Definition: LogEvent.h:54
QString message() const
Definition: LogEvent.cpp:75
Severity _severity
Definition: LogEvent.h:53
Severity severity() const
Definition: LogEvent.cpp:68