logfile.h

Go to the documentation of this file.
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 ** \version $Id: logfile.h 2362 2008-02-29 04:30:11Z edmanm $ 
00014 ** \brief Logs messages from Tor to a file
00015 */
00016 
00017 #ifndef _LOGFILE_H
00018 #define _LOGFILE_H
00019 
00020 #include <QFile>
00021 #include <QObject>
00022 #include <QString>
00023 #include <QTextStream>
00024 
00025 
00026 class LogFile : QObject
00027 {
00028   Q_OBJECT
00029 
00030 public:
00031   /** Default constructor. */
00032   LogFile();
00033   /** Destructor. */
00034   ~LogFile();
00035 
00036   /** Opens a log file for writing. */
00037   bool open(QString filename, QString *errmsg = 0);
00038   /** Closes an open log file. */
00039   void close();
00040   
00041   /** Returns true if the logfile is currently open. */
00042   bool isOpen();
00043   /** Returns the filename of the current log file. */
00044   QString filename();
00045 
00046   /** Overloaded ostream operator. */
00047   LogFile& operator<<(const QString &s);
00048   
00049 private:
00050   /** Creates a path to the given log file */
00051   bool createPathToFile(QString filename);
00052 
00053   QFile* _file;        /**< The log file. */
00054   QTextStream _stream; /**< Stream used to write to the log file. */
00055 };
00056 
00057 #endif
00058 

Generated on Wed Nov 26 21:03:58 2008 for Vidalia by  doxygen 1.5.6