X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Flogger.h;h=0fa4bc7cd029ce7374b3548128c61276d767089f;hb=09d94db2f06ce1521f19566b3d988cff4b02af6b;hp=e3b7ee0a5b8c119559f9fbe26b2aa885a5554f8c;hpb=33141a0825e7cf2dcd0cae63da8943626d8a06b6;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/logger.h b/include/logger.h index e3b7ee0a5..0fa4bc7cd 100644 --- a/include/logger.h +++ b/include/logger.h @@ -1,32 +1,29 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ +/* + * InspIRCd -- Internet Relay Chat Daemon + * + * Copyright (C) 2008 Thomas Stagner + * Copyright (C) 2008 Robin Burchell * - * InspIRCd: (C) 2002-2009 InspIRCd Development Team - * See: http://wiki.inspircd.org/Credits + * This file is part of InspIRCd. InspIRCd is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, version 2. * - * This program is free but copyrighted software; see - * the file COPYING for details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. * - * --------------------------------------------------- + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ -#ifndef __LOGMANAGER_H -#define __LOGMANAGER_H - -/** This class implements a nonblocking writer. - * 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. + +#ifndef LOGGER_H +#define LOGGER_H + +/** Simple wrapper providing periodic flushing to a disk-backed file. */ -class CoreExport FileWriter : public EventHandler +class CoreExport FileWriter { protected: /** The log file (fd is inside this somewhere, @@ -43,14 +40,6 @@ class CoreExport FileWriter : public EventHandler */ FileWriter(FILE* logfile); - /** 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); - /** Write one or more preformatted log lines. * If the data cannot be written immediately, * this class will insert itself into the @@ -60,10 +49,6 @@ class CoreExport FileWriter : public EventHandler */ void WriteLogLine(const std::string &line); - /** Close the log file and cancel any events. - */ - virtual void Close(); - /** Close the log file and cancel any events. */ virtual ~FileWriter(); @@ -124,10 +109,6 @@ class CoreExport LogManager */ bool Logging; - /** LogStream for -nofork, logs to STDOUT when it's active. - */ - LogStream* noforkstream; - /** Map of active log types and what LogStreams will receive them. */ std::map > LogStreams; @@ -150,12 +131,6 @@ class CoreExport LogManager LogManager(); ~LogManager(); - /** 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(); - /** Adds a FileWriter instance to LogManager, or increments the reference count of an existing instance. * Used for file-stream sharing for FileLogStreams. */ @@ -185,7 +160,7 @@ class CoreExport LogManager } } - /** Opens all logfiles defined in the configuration file using . + /** Opens all logfiles defined in the configuration file using \. */ void OpenFileLogs(); @@ -232,7 +207,7 @@ class CoreExport LogManager /** Logs an event, sending it to all LogStreams registered for the type. * @param type Log message type (ex: "USERINPUT", "MODULE", ...) * @param loglevel Log message level (DEBUG, VERBOSE, DEFAULT, SPARSE, NONE) - * @param msg The format of the message to be logged. See your C manual on printf() for details. + * @param fmt The format of the message to be logged. See your C manual on printf() for details. */ void Log(const std::string &type, int loglevel, const char *fmt, ...) CUSTOM_PRINTF(4, 5); };