Vidalia
0.2.21
|
#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.
enum Log::LogLevel |
Log::Log | ( | ) |
Log::~Log | ( | ) |
void Log::close | ( | ) |
|
inline |
Returns a string description of the last file error encountered.
Definition at line 60 of file Log.h.
References _logFile.
Referenced by Vidalia::validateArguments().
|
inline |
Returns true if the log file is open and ready for writing.
Definition at line 58 of file Log.h.
References _logFile.
Referenced by open(), and Vidalia::validateArguments().
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 109 of file Log.cpp.
Referenced by Vidalia::log(), and Log::LogMessage::~LogMessage().
|
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.
|
static |
Returns a list of strings representing valid log levels.
Returns a list of strings representing available log levels.
Definition at line 42 of file Log.cpp.
Referenced by Vidalia::showUsageMessageBox(), and Vidalia::validateArguments().
|
inlinestatic |
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 62 of file Log.cpp.
References _logFile, close(), isOpen(), and LOGFILE_MODE.
Referenced by Vidalia::Vidalia().
bool Log::open | ( | QString | file | ) |
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 52 of file Log.cpp.
References _logFile, _logLevel, Debug, Off, and Unknown.
Referenced by Vidalia::Vidalia().
|
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 132 of file Log.cpp.
References Debug, Error, Info, Notice, Off, Unknown, and Warn.
Referenced by Vidalia::Vidalia().
|
private |
Log output destination.
Definition at line 83 of file Log.h.
Referenced by close(), errorString(), isOpen(), log(), open(), and setLogLevel().
|
private |
Minimum log severity level.
Definition at line 82 of file Log.h.
Referenced by Log(), log(), and setLogLevel().