libktorrent  2.2.0
log.h
1 /***************************************************************************
2  * Copyright (C) 2005 by Joris Guisson *
3  * joris.guisson@gmail.com *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 
21 #ifndef JORISLOG_H
22 #define JORISLOG_H
23 
24 
25 #include "constants.h"
26 #include <QUrl>
27 #include <QString>
28 #include <ktorrent_export.h>
29 
30 // LOG MESSAGES CONSTANTS
31 #define LOG_NONE 0x00
32 #define LOG_IMPORTANT 0x01
33 #define LOG_NOTICE 0x03
34 #define LOG_DEBUG 0x07
35 #define LOG_ALL 0x0F
36 
37 #define SYS_GEN 0x0010 // Genereral info messages
38 #define SYS_CON 0x0020 // Connections
39 #define SYS_TRK 0x0040 // Tracker
40 #define SYS_DHT 0x0080 // DHT
41 #define SYS_DIO 0x0100 // Disk IO related stuff, saving and loading of chunks ...
42 #define SYS_UTP 0x0200 // UTP
43 
44 //plugins
45 #define SYS_IPF 0x1000 // IPFilter
46 #define SYS_SRC 0x2000 // Search plugin
47 #define SYS_PNP 0x4000 // UPnP plugin
48 #define SYS_INW 0x8000 // InfoWidget
49 #define SYS_SNF 0x10000 // ScanFolder plugin
50 #define SYS_MPL 0x20000 // Media player plugin
51 #define SYS_SCD 0x40000 // Scheduler plugin
52 #define SYS_BTF 0x80000 // BitFinder plugin
53 #define SYS_WEB 0x100000 // WebInterface plugin
54 #define SYS_ZCO 0x200000 // ZeroConf plugin
55 #define SYS_SCR 0x400000 // Scripting plugin
56 #define SYS_SYN 0x800000 // Syndication plugin
57 
58 
59 namespace bt
60 {
61  class LogMonitorInterface;
62 
76  class KTORRENT_EXPORT Log
77  {
78  class Private;
79 
80  Private* priv;
81  public:
85  Log();
86 
90  virtual ~Log();
91 
97  void setOutputToConsole(bool on);
98 
104 
110 
118  void setOutputFile(const QString & file,bool rotate,bool handle_qt_messages);
119 
126  template <class T>
127  Log & operator << (T val)
128  {
129  return operator << (QString::number(val));
130  }
131 
137  Log & operator << (Log & (*func)(Log & ))
138  {
139  return func(*this);
140  }
141 
142 
148  Log & operator << (const char* s);
149 
155  Log & operator << (const QString & s);
156 
162  Log & operator << (Uint64 v);
163 
169  Log & operator << (Int64 v);
170 
176  KTORRENT_EXPORT friend Log & endl(Log & lg);
177 
183  Log & operator << (const QUrl & url);
184 
189  void setFilter(unsigned int filter);
190 
192  void lock();
193 
196  };
197 
198  KTORRENT_EXPORT Log & endl(Log & lg);
199  KTORRENT_EXPORT Log & Out(unsigned int arg = 0x00);
200 
201 
209  KTORRENT_EXPORT void InitLog(const QString & file,bool rotate_logs = false,bool handle_qt_messages = true,bool to_stdout = false);
210 
212  KTORRENT_EXPORT void AddLogMonitor(LogMonitorInterface* m);
213 
215  KTORRENT_EXPORT void RemoveLogMonitor(LogMonitorInterface* m);
216 }
217 
218 #endif
bt::Log::Log
Log()
bt::Log::~Log
virtual ~Log()
bt::Log
Class which writes messages to a logfile.
Definition: log.h:77
bt::Log::endl
KTORRENT_EXPORT friend Log & endl(Log &lg)
bt::Log::lock
void lock()
Lock the mutex of the log, should be called in Out()
bt::Log::setFilter
void setFilter(unsigned int filter)
bt::Log::removeMonitor
void removeMonitor(LogMonitorInterface *m)
bt::Log::setOutputToConsole
void setOutputToConsole(bool on)
bt::Log::setOutputFile
void setOutputFile(const QString &file, bool rotate, bool handle_qt_messages)
bt::Log::logRotateDone
void logRotateDone()
Called by the auto log rotate job when it has finished.
bt::Log::addMonitor
void addMonitor(LogMonitorInterface *m)
bt::LogMonitorInterface
Interface for classes who which to receive which log messages are printed.
Definition: logmonitorinterface.h:38