* | Inspire Internet Relay Chat Daemon |
* +------------------------------------+
*
- * InspIRCd: (C) 2002-2008 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
+ * InspIRCd: (C) 2002-2010 InspIRCd Development Team
+ * See: http://wiki.inspircd.org/Credits
*
* This program is free but copyrighted software; see
* the file COPYING for details.
* I/O (linux seems to, as does freebsd) this will default to
* blocking behaviour.
*/
-class CoreExport FileWriter : public EventHandler
+class CoreExport FileWriter
{
protected:
- /** The creator/owner of this object
- */
- InspIRCd* ServerInstance;
-
/** The log file (fd is inside this somewhere,
* we get it out with fileno())
*/
FILE* log;
- /** Buffer of pending log lines to be written
- */
- std::string buffer;
-
/** Number of write operations that have occured
*/
int writeops;
public:
/** The constructor takes an already opened logfile.
*/
- FileWriter(InspIRCd* Instance, FILE* logfile);
-
- /** This returns false, logfiles are writeable.
- */
- virtual bool Readable();
-
- /** Handle pending write events.
- * This will flush any waiting data to disk.
- * If any data remains after the fprintf call,
- * another write event is scheduled to write
- * the rest of the data when possible.
- */
- virtual void HandleEvent(EventType et, int errornum = 0);
+ FileWriter(FILE* logfile);
/** Write one or more preformatted log lines.
* If the data cannot be written immediately,
/** Close the log file and cancel any events.
*/
- virtual void Close();
-
- /** Close the log file and cancel any events.
- * (indirectly call Close()
- */
virtual ~FileWriter();
};
class CoreExport LogStream : public classbase
{
protected:
- InspIRCd *ServerInstance;
int loglvl;
public:
- LogStream(InspIRCd *Instance, int loglevel) : ServerInstance(Instance), loglvl(loglevel)
+ LogStream(int loglevel) : loglvl(loglevel)
{
}
typedef std::map<FileWriter*, int> FileLogMap;
-class CoreExport LogManager : public classbase
+class CoreExport LogManager
{
private:
/** Lock variable, set to true when a log is in progress, which prevents further loggging from happening and creating a loop.
*/
bool Logging;
- /** LogStream for -nofork, logs to STDOUT when it's active.
- */
- LogStream* noforkstream;
-
- InspIRCd *ServerInstance;
-
/** Map of active log types and what LogStreams will receive them.
*/
std::map<std::string, std::vector<LogStream *> > LogStreams;
public:
- LogManager(InspIRCd *Instance)
- {
- noforkstream = NULL;
- ServerInstance = Instance;
- Logging = false;
- }
-
- /** Sets up the logstream for -nofork. Called by InspIRCd::OpenLog() and LogManager::OpenFileLogs().
- * First time called it creates the nofork stream and stores it in noforkstream. Each call thereafter just readds it to GlobalLogStreams
- * and updates the loglevel.
- */
- void SetupNoFork();
+ LogManager();
+ ~LogManager();
/** Adds a FileWriter instance to LogManager, or increments the reference count of an existing instance.
* Used for file-stream sharing for FileLogStreams.