logevent.cpp

Go to the documentation of this file.
00001 /****************************************************************
00002  *  Vidalia is distributed under the following license:
00003  *
00004  *  Copyright (C) 2006,  Matt Edman, Justin Hipple
00005  *
00006  *  This program is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU General Public License
00008  *  as published by the Free Software Foundation; either version 2
00009  *  of the License, or (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, 
00019  *  Boston, MA  02110-1301, USA.
00020  ****************************************************************/
00021 
00022 /** 
00023  * \file logevent.cpp
00024  * \version $Id: logevent.cpp 1238 2006-09-25 17:50:57Z edmanm $
00025  * \brief Event dispatched containing a log message from Tor
00026  */
00027 
00028 #include "eventtype.h"
00029 #include "logevent.h"
00030 
00031 
00032 /** Default constructor */
00033 LogEvent::LogEvent(Severity severity, QString message)
00034 : QEvent((QEvent::Type)CustomEventType::LogEvent)
00035 {
00036   _severity = severity;
00037   _message  = message;
00038 }
00039 
00040 /** Converts a string description of a severity to its enum value */
00041 LogEvent::Severity
00042 LogEvent::toSeverity(QString strSeverity)
00043 {
00044   Severity s;
00045   strSeverity = strSeverity.toUpper();
00046   if (strSeverity == "DEBUG") {
00047     s = Debug;
00048   } else if (strSeverity == "INFO") {
00049     s = Info;
00050   } else if (strSeverity == "NOTICE") {
00051     s = Notice;
00052   } else if (strSeverity == "WARN") {
00053     s = Warn;
00054   } else if (strSeverity == "ERR" || strSeverity == "ERROR") {
00055     s = Error;
00056   } else {
00057     s = Unknown;
00058   }
00059   return s;
00060 }
00061 
00062 /** Converts a Severity enum value to a string description */
00063 QString
00064 LogEvent::severityToString(Severity s)
00065 {
00066   QString str;
00067   switch (s) {
00068     case Debug:  str = tr("Debug"); break;
00069     case Info:   str = tr("Info"); break;
00070     case Notice: str = tr("Notice"); break;
00071     case Warn:   str = tr("Warning"); break;
00072     case Error:  str = tr("Error"); break;
00073     default: str = tr("Unknown"); break;
00074   }
00075   return str;
00076 }
00077 
00078 /** Returns the severity of this log event */
00079 LogEvent::Severity
00080 LogEvent::severity()
00081 {
00082   return _severity;
00083 }
00084 
00085 /** Returns the message for this log event */
00086 QString
00087 LogEvent::message()
00088 {
00089   return _message;
00090 }
00091 

Generated on Mon Oct 23 20:08:16 2006 for Vidalia by  doxygen 1.5.0