Vidalia 0.2.12
|
00001 /* 00002 ** This file is part of Vidalia, and is subject to the license terms in the 00003 ** LICENSE file, found in the top level directory of this distribution. If you 00004 ** did not receive the LICENSE file with this file, you may obtain it from the 00005 ** Vidalia source package distributed by the Vidalia Project at 00006 ** http://www.vidalia-project.net/. No part of Vidalia, including this file, 00007 ** may be copied, modified, propagated, or distributed except according to the 00008 ** terms described in the LICENSE file. 00009 */ 00010 00011 /* 00012 ** \file LogFile.h 00013 ** \brief Logs messages from Tor to a file 00014 */ 00015 00016 #ifndef _LOGFILE_H 00017 #define _LOGFILE_H 00018 00019 #include <QFile> 00020 #include <QObject> 00021 #include <QString> 00022 #include <QTextStream> 00023 00024 00025 class LogFile : QObject 00026 { 00027 Q_OBJECT 00028 00029 public: 00030 /** Default constructor. */ 00031 LogFile(); 00032 /** Destructor. */ 00033 ~LogFile(); 00034 00035 /** Opens a log file for writing. */ 00036 bool open(QString filename, QString *errmsg = 0); 00037 /** Closes an open log file. */ 00038 void close(); 00039 00040 /** Returns true if the logfile is currently open. */ 00041 bool isOpen(); 00042 /** Returns the filename of the current log file. */ 00043 QString filename(); 00044 00045 /** Overloaded ostream operator. */ 00046 LogFile& operator<<(const QString &s); 00047 00048 private: 00049 /** Creates a path to the given log file */ 00050 bool createPathToFile(QString filename); 00051 00052 QFile* _file; /**< The log file. */ 00053 QTextStream _stream; /**< Stream used to write to the log file. */ 00054 }; 00055 00056 #endif 00057