#include <log.h>
Classes | |
class | LogMessage |
Public Types | |
enum | LogLevel { Debug = 0, Info, Notice, Warn, Error, Off, Unknown } |
Public Member Functions | |
Log () | |
~Log () | |
bool | open (FILE *file) |
bool | open (QString file) |
void | close () |
bool | isOpen () |
QString | errorString () |
void | setLogLevel (LogLevel level) |
LogMessage | log (LogLevel level, QString message) |
LogMessage | log (LogLevel level) |
Static Public Member Functions | |
static QStringList | logLevels () |
static QString | logLevelToString (LogLevel level) |
static LogLevel | stringToLogLevel (QString str) |
Private Attributes | |
LogLevel | _logLevel |
QFile | _logFile |
The Log class is similar to the QDebug class provided with Qt, but with finer-grained logging levels, slightly different output (for example, not everything is wrapped in double quotes), supports using .arg(), and can still be used even if Qt was compiled with QT_NO_DEBUG_STREAM.
Definition at line 31 of file log.h.
enum Log::LogLevel |
Log::Log | ( | ) |
Log::~Log | ( | ) |
void Log::close | ( | ) |
QString Log::errorString | ( | ) | [inline] |
Returns a string description of the last file error encountered.
Definition at line 61 of file log.h.
References _logFile.
Referenced by Vidalia::validateArguments().
bool Log::isOpen | ( | ) | [inline] |
Returns true if the log file is open and ready for writing.
Definition at line 59 of file log.h.
References _logFile.
Referenced by open(), and Vidalia::validateArguments().
Log::LogMessage Log::log | ( | LogLevel | level | ) | [inline] |
Creates a log message with severity level. The log message can be appended to until the returned LogMessage's destructor is called, at which point the complete message is written to the log file.
Creates a log message with severity level and initial message contents message. The log message can be appended to until the returned LogMessage's destructor is called, at which point the complete message is written to the log file.
Log::LogMessage Log::log | ( | LogLevel | level, | |
QString | msg | |||
) |
Creates a log message with severity level and initial message contents message. The log message can be appended to until the returned LogMessage's destructor is called, at which point the complete message is written to the log file.
Creates a log message with severity level. The log message can be appended to until the returned LogMessage's destructor is called, at which point the complete message is written to the log file.
Definition at line 110 of file log.cpp.
Referenced by Vidalia::log(), and Log::LogMessage::~LogMessage().
QStringList Log::logLevels | ( | ) | [static] |
Returns a list of strings representing valid log levels.
Returns a list of strings representing available log levels.
Definition at line 43 of file log.cpp.
Referenced by Vidalia::showUsageMessageBox(), and Vidalia::validateArguments().
QString Log::logLevelToString | ( | LogLevel | level | ) | [inline, static] |
bool Log::open | ( | QString | file | ) |
bool Log::open | ( | FILE * | file | ) |
Opens a file on disk (or stdout or stderr) to which log messages will be written.
Opens file for appending, to which log messages will be written.
Definition at line 63 of file log.cpp.
References _logFile, close(), isOpen(), and LOGFILE_MODE.
Referenced by Vidalia::Vidalia().
void Log::setLogLevel | ( | LogLevel | level | ) |
Sets the current log level to level.
Sets the current log level to level. If level is Off, then the log file will be closed as well. If level is Unknown, no change to the current log level is made.
Definition at line 53 of file log.cpp.
References _logFile, _logLevel, Debug, Off, and Unknown.
Referenced by Vidalia::Vidalia().
Log::LogLevel Log::stringToLogLevel | ( | QString | str | ) | [static] |
Returns a LogLevel for the level given by str.
Returns a LogLevel for the level given by str, or Unknown if the given string does not represent a valid LogLevel value.
Definition at line 133 of file log.cpp.
References Debug, Error, Info, Notice, Off, Unknown, and Warn.
Referenced by Vidalia::Vidalia().
QFile Log::_logFile [private] |
Log output destination.
Definition at line 84 of file log.h.
Referenced by close(), errorString(), isOpen(), log(), open(), and setLogLevel().
LogLevel Log::_logLevel [private] |
Minimum log severity level.
Definition at line 83 of file log.h.
Referenced by log(), Log(), and setLogLevel().