|
|||
|
|||
|
#include <inspircd.h>
Collaboration diagram for FileLogger:

Public Member Functions | |
| FileLogger (InspIRCd *Instance, FILE *logfile) | |
| The constructor takes an already opened logfile. | |
| void | WriteLogLine (const std::string &line) |
| Write one or more preformatted log lines. | |
| virtual void | Close () |
| Close the log file and cancel any events. | |
| virtual | ~FileLogger () |
| Close the log file and cancel any events. | |
Protected Attributes | |
| InspIRCd * | ServerInstance |
| The creator/owner of this object. | |
| FILE * | log |
| The log file (fd is inside this somewhere, we get it out with fileno()). | |
| int | writeops |
| Number of write operations that have occured. | |
Most people writing an ircd give little thought to their disk i/o. On a congested system, disk writes can block for long periods of time (e.g. if the system is busy and/or swapping a lot). If we just use a blocking fprintf() call, this could block for undesirable amounts of time (half of a second through to whole seconds). We DO NOT want this, so we make our logfile nonblocking and hook it into the SocketEngine. NB: If the operating system does not support nonblocking file I/O (linux seems to, as does freebsd) this will default to blocking behaviour.
Definition at line 273 of file inspircd.h.
|
||||||||||||
|
The constructor takes an already opened logfile.
Definition at line 1297 of file inspircd.cpp. 01297 : ServerInstance(Instance), log(logfile), writeops(0) 01298 { 01299 }
|
|
|
Close the log file and cancel any events. (indirectly call Close() Definition at line 1301 of file inspircd.cpp. References Close(). 01302 { 01303 this->Close(); 01304 }
|
|
|
Close the log file and cancel any events.
Definition at line 1288 of file inspircd.cpp. References log. Referenced by InspIRCd::Cleanup(), InspIRCd::CloseLog(), and ~FileLogger().
|
|
|
Write one or more preformatted log lines. If the data cannot be written immediately, this class will insert itself into the SocketEngine, and register a write event, and when the write event occurs it will attempt again to write the data. Definition at line 1275 of file inspircd.cpp. Referenced by InspIRCd::Log(). 01276 { 01277 if (log) 01278 { 01279 fprintf(log,"%s", line.c_str()); 01280 01281 if (writeops++ % 20) 01282 { 01283 fflush(log); 01284 } 01285 } 01286 }
|
|
|
The log file (fd is inside this somewhere, we get it out with fileno()).
Definition at line 283 of file inspircd.h. Referenced by Close(), and WriteLogLine(). |
|
|
The creator/owner of this object.
Definition at line 278 of file inspircd.h. |
|
|
Number of write operations that have occured.
Definition at line 287 of file inspircd.h. Referenced by WriteLogLine(). |