libktorrent  2.1.1
Public Member Functions | Friends | List of all members
bt::Log Class Reference

Class which writes messages to a logfile. More...

#include <log.h>

Public Member Functions

 Log ()
 
virtual ~Log ()
 
void addMonitor (LogMonitorInterface *m)
 
void lock ()
 Lock the mutex of the log, should be called in Out()
 
void logRotateDone ()
 Called by the auto log rotate job when it has finished.
 
Logoperator<< (const char *s)
 
Logoperator<< (const QString &s)
 
Logoperator<< (const QUrl &url)
 
Logoperator<< (Int64 v)
 
Logoperator<< (Log &(*func)(Log &))
 
template<class T >
Logoperator<< (T val)
 
Logoperator<< (Uint64 v)
 
void removeMonitor (LogMonitorInterface *m)
 
void setFilter (unsigned int filter)
 
void setOutputFile (const QString &file, bool rotate, bool handle_qt_messages)
 
void setOutputToConsole (bool on)
 

Friends

KTORRENT_EXPORT friend Logendl (Log &lg)
 

Detailed Description

Author
Joris Guisson This class writes messages to a logfile. To use it, create an instance, set the output file and write stuff with the << operator.

By default all messages will also be printed on the standard output. This can be turned down using the setOutputToConsole function.

There is also the possibility to monitor what is written to the log using the LogMonitorInterface class.

Definition at line 76 of file log.h.

Constructor & Destructor Documentation

◆ Log()

bt::Log::Log ( )

Constructor.

◆ ~Log()

virtual bt::Log::~Log ( )
virtual

Destructor, closes the file.

Member Function Documentation

◆ addMonitor()

void bt::Log::addMonitor ( LogMonitorInterface m)

Add a log monitor.

Parameters
mThe log monitor

◆ operator<<() [1/7]

Log& bt::Log::operator<< ( const char *  s)

Output a QString to the log.

Parameters
sThe QString
Returns
This Log

◆ operator<<() [2/7]

Log& bt::Log::operator<< ( const QString &  s)

Output a QString to the log.

Parameters
sThe QString
Returns
This Log

◆ operator<<() [3/7]

Log& bt::Log::operator<< ( const QUrl &  url)

Write an URL to the file.

Parameters
textThe QUrl
Returns
This Log

◆ operator<<() [4/7]

Log& bt::Log::operator<< ( Int64  v)

Output a 64 bit integer to the log.

Parameters
vThe integer
Returns
This Log

◆ operator<<() [5/7]

Log& bt::Log::operator<< ( Log &(*)(Log &)  func)
inline

Apply a function to the Log.

Parameters
funcThe function
Returns
This Log

Definition at line 137 of file log.h.

◆ operator<<() [6/7]

template<class T >
Log& bt::Log::operator<< ( val)
inline

Write a number to the log file. Anything which can be passed to QString::number will do.

Parameters
valThe value
Returns
This Log

Definition at line 127 of file log.h.

◆ operator<<() [7/7]

Log& bt::Log::operator<< ( Uint64  v)

Output a 64 bit integer to the log.

Parameters
vThe integer
Returns
This Log

◆ removeMonitor()

void bt::Log::removeMonitor ( LogMonitorInterface m)

Remove a log monitor. It will not be deleted.

Parameters
mThe log monitor

◆ setFilter()

void bt::Log::setFilter ( unsigned int  filter)

Sets a filter for log messages. Applies only to listeners via LogMonitorInterface!

Parameters
filterSYS & LOG flags combined with bitwise OR.

◆ setOutputFile()

void bt::Log::setOutputFile ( const QString &  file,
bool  rotate,
bool  handle_qt_messages 
)

Set the output logfile.

Parameters
fileThe name of the file
rotateWhether or not to rotate the logs
boolhandle_qt_messages Whether or not handle Qt messages
Exceptions
Exceptionif the file can't be opened

◆ setOutputToConsole()

void bt::Log::setOutputToConsole ( bool  on)

Enable or disable the printing of log messages to the standard output.

Parameters
onEnable or disable

Friends And Related Function Documentation

◆ endl

KTORRENT_EXPORT friend Log& endl ( Log lg)
friend

Prints and endline character to the Log and flushes it.

Parameters
lgThe Log
Returns
lg

The documentation for this class was generated from the following file: