summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.Makefile.inc1
-rwxr-xr-xconfigure20
-rw-r--r--include/inspircd.h73
-rw-r--r--src/inspircd.cpp86
4 files changed, 16 insertions, 164 deletions
diff --git a/.Makefile.inc b/.Makefile.inc
index e008397b0..ad46ba780 100644
--- a/.Makefile.inc
+++ b/.Makefile.inc
@@ -95,6 +95,7 @@ install: all@EXTRA_DIR@
-install -m $(INSTMODE) src/libIRCDtimer.$(LIB_EXT) $(LIBPATH)
-install -m $(INSTMODE) src/libIRCDsnomasks.$(LIB_EXT) $(LIBPATH)
-install -m $(INSTMODE) src/libIRCDserver.$(LIB_EXT) $(LIBPATH)
+ -install -m $(INSTMODE) src/libIRCDfilelogger.$(LIB_EXT) $(LIBPATH)
-install -m $(INSTMODE) src/inspircd $(BINPATH)
-install -m $(INSTMODE) @STARTSCRIPT@ $(@DESTINATION@) 2>/dev/null
-install -m $(INSTMODE) src/cmd_admin.so $(LIBPATH)
diff --git a/configure b/configure
index f29f44b7a..ed80e9c41 100755
--- a/configure
+++ b/configure
@@ -1324,11 +1324,11 @@ EOM
if ($config{IS_DARWIN} eq "YES") {
print FH <<EOM;
-all: libIRCDtimer.dylib libIRCDcull_list.dylib libIRCDuserprocess.dylib libIRCDsocketengine.dylib libIRCDsocket.dylib libIRCDhash.dylib libIRCDchannels.dylib libIRCDmode.dylib libIRCDxline.dylib libIRCDstring.dylib libIRCDasyncdns.dylib libIRCDbase.dylib libIRCDconfigreader.dylib libIRCDinspsocket.dylib libIRCDcommands.dylib libIRCDdynamic.dylib libIRCDusers.dylib libIRCDmodules.dylib libIRCDwildcard.dylib libIRCDhelper.dylib libIRCDcommand_parse.dylib libIRCDsnomasks.dylib libIRCDserver.dylib inspircd
+all: libIRCDtimer.dylib libIRCDcull_list.dylib libIRCDuserprocess.dylib libIRCDsocketengine.dylib libIRCDsocket.dylib libIRCDhash.dylib libIRCDchannels.dylib libIRCDmode.dylib libIRCDxline.dylib libIRCDstring.dylib libIRCDasyncdns.dylib libIRCDbase.dylib libIRCDconfigreader.dylib libIRCDinspsocket.dylib libIRCDcommands.dylib libIRCDdynamic.dylib libIRCDusers.dylib libIRCDmodules.dylib libIRCDwildcard.dylib libIRCDhelper.dylib libIRCDcommand_parse.dylib libIRCDsnomasks.dylib libIRCDserver.dylib libIRCDfilelogger.dylib inspircd
-inspircd: inspircd.cpp ../include/base.h ../include/channels.h ../include/inspircd.h ../include/channels.h ../include/globals.h ../include/inspircd_config.h ../include/socket.h $cmdobjs libIRCDtimer.dylib libIRCDcull_list.dylib libIRCDuserprocess.dylib libIRCDsocketengine.dylib libIRCDsocket.dylib libIRCDhash.dylib libIRCDchannels.dylib libIRCDmode.dylib libIRCDxline.dylib libIRCDstring.dylib libIRCDasyncdns.dylib libIRCDbase.dylib libIRCDconfigreader.dylib libIRCDinspsocket.dylib libIRCDsnomasks.dylib libIRCDcommands.dylib libIRCDdynamic.dylib libIRCDusers.dylib libIRCDmodules.dylib libIRCDwildcard.dylib libIRCDhelper.dylib libIRCDcommand_parse.dylib libIRCDserver.dylib
+inspircd: inspircd.cpp ../include/base.h ../include/channels.h ../include/inspircd.h ../include/channels.h ../include/globals.h ../include/inspircd_config.h ../include/socket.h $cmdobjs libIRCDtimer.dylib libIRCDcull_list.dylib libIRCDuserprocess.dylib libIRCDsocketengine.dylib libIRCDsocket.dylib libIRCDhash.dylib libIRCDchannels.dylib libIRCDmode.dylib libIRCDxline.dylib libIRCDstring.dylib libIRCDasyncdns.dylib libIRCDbase.dylib libIRCDconfigreader.dylib libIRCDinspsocket.dylib libIRCDsnomasks.dylib libIRCDcommands.dylib libIRCDdynamic.dylib libIRCDusers.dylib libIRCDmodules.dylib libIRCDwildcard.dylib libIRCDhelper.dylib libIRCDcommand_parse.dylib libIRCDserver.dylib libIRCDfilelogger.dylib
\$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c inspircd.cpp
- \$(CC) -pipe -dynamic -bind_at_load -L. -o inspircd \$(LDLIBS) inspircd.o libIRCDchannels.dylib libIRCDmode.dylib libIRCDxline.dylib libIRCDstring.dylib libIRCDasyncdns.dylib libIRCDbase.dylib libIRCDconfigreader.dylib libIRCDinspsocket.dylib libIRCDcommands.dylib libIRCDdynamic.dylib libIRCDusers.dylib libIRCDmodules.dylib libIRCDwildcard.dylib libIRCDhelper.dylib libIRCDhash.dylib libIRCDsocket.dylib libIRCDsocketengine.dylib libIRCDuserprocess.dylib libIRCDcull_list.dylib libIRCDcommand_parse.dylib libIRCDtimer.dylib libIRCDsnomasks.dylib libIRCDserver.dylib
+ \$(CC) -pipe -dynamic -bind_at_load -L. -o inspircd \$(LDLIBS) inspircd.o libIRCDchannels.dylib libIRCDmode.dylib libIRCDxline.dylib libIRCDstring.dylib libIRCDasyncdns.dylib libIRCDbase.dylib libIRCDconfigreader.dylib libIRCDinspsocket.dylib libIRCDcommands.dylib libIRCDdynamic.dylib libIRCDusers.dylib libIRCDmodules.dylib libIRCDwildcard.dylib libIRCDhelper.dylib libIRCDhash.dylib libIRCDsocket.dylib libIRCDsocketengine.dylib libIRCDuserprocess.dylib libIRCDcull_list.dylib libIRCDcommand_parse.dylib libIRCDtimer.dylib libIRCDsnomasks.dylib libIRCDserver.dylib libIRCDfilelogger.dylib
libIRCDsocketengine.dylib: $se.cpp socketengine.cpp ../include/base.h ../include/hashcomp.h ../include/globals.h ../include/inspircd_config.h ../include/$se.h
\$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c socketengine.cpp
@@ -1424,15 +1424,19 @@ libIRCDserver.dylib: server.cpp ../include/base.h ../include/inspircd.h ../inclu
\$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c server.cpp
\$(CC) -pipe -install_name $config{LIBRARY_DIR}/libIRCDserver.dylib -dynamiclib -twolevel_namespace -undefined dynamic_lookup -o libIRCDserver.dylib server.o
+libIRCDfilelogger.dylib: filelogger.cpp ../include/base.h ../include/inspircd.h ../include/globals.h ../include/inspircd_config.h
+ \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c filelogger.cpp
+ \$(CC) -pipe -install_name $config{LIBRARY_DIR}/libIRCDfilelogger.dylib -dynamiclib -twolevel_namespace -undefined dynamic_lookup -o libIRCDfilelogger.dylib filelogger.o
+
EOM
} else {
print FH <<EOM;
-all: libIRCDtimer.so libIRCDcull_list.so libIRCDuserprocess.so libIRCDsocketengine.so libIRCDsocket.so libIRCDhash.so libIRCDchannels.so libIRCDmode.so libIRCDxline.so libIRCDstring.so libIRCDasyncdns.so libIRCDbase.so libIRCDconfigreader.so libIRCDinspsocket.so $cmdobjs libIRCDcommands.so libIRCDdynamic.so libIRCDusers.so libIRCDmodules.so libIRCDwildcard.so libIRCDhelper.so libIRCDcommand_parse.so libIRCDsnomasks.so libIRCDserver.so inspircd
+all: libIRCDtimer.so libIRCDcull_list.so libIRCDuserprocess.so libIRCDsocketengine.so libIRCDsocket.so libIRCDhash.so libIRCDchannels.so libIRCDmode.so libIRCDxline.so libIRCDstring.so libIRCDasyncdns.so libIRCDbase.so libIRCDconfigreader.so libIRCDinspsocket.so $cmdobjs libIRCDcommands.so libIRCDdynamic.so libIRCDusers.so libIRCDmodules.so libIRCDwildcard.so libIRCDhelper.so libIRCDcommand_parse.so libIRCDsnomasks.so libIRCDserver.so libIRCDfilelogger.so inspircd
-inspircd: inspircd.cpp ../include/base.h ../include/channels.h ../include/inspircd.h ../include/channels.h ../include/globals.h ../include/inspircd_config.h ../include/socket.h libIRCDtimer.so libIRCDcull_list.so libIRCDuserprocess.so libIRCDsocketengine.so libIRCDsocket.so libIRCDhash.so libIRCDchannels.so libIRCDmode.so libIRCDxline.so libIRCDstring.so libIRCDasyncdns.so libIRCDbase.so libIRCDconfigreader.so libIRCDinspsocket.so $cmdobjs libIRCDsnomasks.so libIRCDcommands.so libIRCDdynamic.so libIRCDusers.so libIRCDmodules.so libIRCDwildcard.so libIRCDhelper.so libIRCDcommand_parse.so libIRCDserver.so
- \$(CC) -pipe -I../include -Wl,--rpath -Wl,$config{LIBRARY_DIR} \$(FLAGS) -rdynamic -L. inspircd.cpp -o inspircd \$(LDLIBS) libIRCDchannels.so libIRCDmode.so libIRCDxline.so libIRCDstring.so libIRCDasyncdns.so libIRCDbase.so libIRCDconfigreader.so libIRCDinspsocket.so libIRCDcommands.so libIRCDdynamic.so libIRCDusers.so libIRCDmodules.so libIRCDwildcard.so libIRCDhelper.so libIRCDhash.so libIRCDsocket.so libIRCDsocketengine.so libIRCDuserprocess.so libIRCDcull_list.so libIRCDcommand_parse.so libIRCDtimer.so libIRCDsnomasks.so libIRCDserver.so
+inspircd: inspircd.cpp ../include/base.h ../include/channels.h ../include/inspircd.h ../include/channels.h ../include/globals.h ../include/inspircd_config.h ../include/socket.h libIRCDtimer.so libIRCDcull_list.so libIRCDuserprocess.so libIRCDsocketengine.so libIRCDsocket.so libIRCDhash.so libIRCDchannels.so libIRCDmode.so libIRCDxline.so libIRCDstring.so libIRCDasyncdns.so libIRCDbase.so libIRCDconfigreader.so libIRCDinspsocket.so $cmdobjs libIRCDsnomasks.so libIRCDcommands.so libIRCDdynamic.so libIRCDusers.so libIRCDmodules.so libIRCDwildcard.so libIRCDhelper.so libIRCDcommand_parse.so libIRCDserver.so libIRCDfilelogger.so
+ \$(CC) -pipe -I../include -Wl,--rpath -Wl,$config{LIBRARY_DIR} \$(FLAGS) -rdynamic -L. inspircd.cpp -o inspircd \$(LDLIBS) libIRCDchannels.so libIRCDmode.so libIRCDxline.so libIRCDstring.so libIRCDasyncdns.so libIRCDbase.so libIRCDconfigreader.so libIRCDinspsocket.so libIRCDcommands.so libIRCDdynamic.so libIRCDusers.so libIRCDmodules.so libIRCDwildcard.so libIRCDhelper.so libIRCDhash.so libIRCDsocket.so libIRCDsocketengine.so libIRCDuserprocess.so libIRCDcull_list.so libIRCDcommand_parse.so libIRCDtimer.so libIRCDsnomasks.so libIRCDserver.so libIRCDfilelogger.so
libIRCDsocketengine.so: $se.cpp socketengine.cpp ../include/base.h ../include/hashcomp.h ../include/globals.h ../include/inspircd_config.h ../include/$se.h
\$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c socketengine.cpp $se.cpp
@@ -1527,6 +1531,10 @@ libIRCDserver.so: server.cpp ../include/base.h ../include/inspircd.h ../include/
\$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c server.cpp
\$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDserver.so server.o
+libIRCDfilelogger.so: filelogger.cpp ../include/base.h ../include/inspircd.h ../include/globals.h ../include/inspircd_config.h
+ \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c filelogger.cpp
+ \$(CC) -pipe -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDfilelogger.so filelogger.o
+
EOM
}
foreach my $cmd (@cmdlist) {
diff --git a/include/inspircd.h b/include/inspircd.h
index f21e03272..b7aa7628b 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -37,6 +37,7 @@
#include "command_parse.h"
#include "snomasks.h"
#include "cull_list.h"
+#include "filelogger.h"
/**
* Used to define the maximum number of parameters a command may have.
@@ -52,16 +53,6 @@
*/
#define ETIREDHAMSTERS EAGAIN
-/** Debug levels for use with InspIRCd::Log()
- */
-enum DebugLevel
-{
- DEBUG = 10,
- VERBOSE = 20,
- DEFAULT = 30,
- SPARSE = 40,
- NONE = 50
-};
/**
* This define is used in place of strcmp when we
@@ -238,68 +229,6 @@ class serverstats : public classbase
}
};
-/* Forward declaration -- required */
-class InspIRCd;
-
-/** This class implements a nonblocking log-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.
- */
-class CoreExport FileLogger : public EventHandler
-{
- 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.
- */
- FileLogger(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);
- /** 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.
- */
- 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.
- * (indirectly call Close()
- */
- virtual ~FileLogger();
-};
-
/** A list of failed port bindings, used for informational purposes on startup */
typedef std::vector<std::pair<std::string, long> > FailedPortList;
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 44f658427..d039d7314 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -811,89 +811,3 @@ int InspIRCd::GetTimeDelta()
{
return time_delta;
}
-
-bool FileLogger::Readable()
-{
- return false;
-}
-
-void FileLogger::HandleEvent(EventType et, int errornum)
-{
- this->WriteLogLine("");
- if (log)
- ServerInstance->SE->DelFd(this);
-}
-
-void FileLogger::WriteLogLine(const std::string &line)
-{
- if (line.length())
- buffer.append(line);
-
- if (log)
- {
- int written = fprintf(log,"%s",buffer.c_str());
-#ifdef WINDOWS
- buffer.clear();
-#else
- if ((written >= 0) && (written < (int)buffer.length()))
- {
- buffer.erase(0, buffer.length());
- ServerInstance->SE->AddFd(this);
- }
- else if (written == -1)
- {
- if (errno == EAGAIN)
- ServerInstance->SE->AddFd(this);
- }
- else
- {
- /* Wrote the whole buffer, and no need for write callback */
- buffer.clear();
- }
-#endif
- if (writeops++ % 20)
- {
- fflush(log);
- }
- }
-}
-
-void FileLogger::Close()
-{
- if (log)
- {
- /* Burlex: Windows assumes nonblocking on FILE* pointers anyway, and also "file" fd's aren't the same
- * as socket fd's. */
-#ifndef WIN32
- int flags = fcntl(fileno(log), F_GETFL, 0);
- fcntl(fileno(log), F_SETFL, flags ^ O_NONBLOCK);
-#endif
- if (buffer.size())
- fprintf(log,"%s",buffer.c_str());
-
-#ifndef WINDOWS
- ServerInstance->SE->DelFd(this);
-#endif
-
- fflush(log);
- fclose(log);
- }
-
- buffer.clear();
-}
-
-FileLogger::FileLogger(InspIRCd* Instance, FILE* logfile) : ServerInstance(Instance), log(logfile), writeops(0)
-{
- if (log)
- {
- irc::sockets::NonBlocking(fileno(log));
- this->SetFd(fileno(log));
- buffer.clear();
- }
-}
-
-FileLogger::~FileLogger()
-{
- this->Close();
-}
-