]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/helperfuncs.cpp
Annotations
[user/henk/code/inspircd.git] / src / helperfuncs.cpp
index 44958d44f471c4b15d04b30bb34f53b3a3105373..4afe7afeba1fcdfcdd4774666c3261609b3d795a 100644 (file)
  */
 
 #include <stdarg.h>
-#include "inspircd_config.h"
 #include "configreader.h"
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/errno.h>
-#include <signal.h>
-#include <time.h>
-#include <string>
-#include <sstream>
-#ifdef HAS_EXECINFO
-#include <execinfo.h>
-#endif
-#include "connection.h"
 #include "users.h"
-#include "ctables.h"
-#include "globals.h"
 #include "modules.h"
-#include "dynamic.h"
 #include "wildcard.h"
 #include "mode.h"
 #include "xline.h"
-#include "commands.h"
-#include "inspstring.h"
-#include "helperfuncs.h"
-#include "hashcomp.h"
-#include "typedefs.h"
 #include "inspircd.h"
 
 static char TIMESTR[26];
@@ -83,8 +63,8 @@ void InspIRCd::Log(int level, const std::string &text)
 
        if (Config->log_file && Config->writelog)
        {
-               fprintf(Config->log_file,"%s %s\n",TIMESTR,text.c_str());
-               fflush(Config->log_file);
+               std::string out = std::string(TIMESTR) + " " + text.c_str() + "\n";
+               this->Logger->WriteLogLine(out);
        }
 
        if (Config->nofork)
@@ -192,7 +172,7 @@ void InspIRCd::WriteMode(const char* modes, int flags, const char* text, ...)
 
        if ((!text) || (!modes) || (!flags))
        {
-               ilog(this,DEFAULT,"*** BUG *** WriteMode was given an invalid parameter");
+               this->Log(DEFAULT,"*** BUG *** WriteMode was given an invalid parameter");
                return;
        }
 
@@ -320,13 +300,13 @@ void InspIRCd::SendError(const char *s)
 }
 
 // this function counts all users connected, wether they are registered or NOT.
-int InspIRCd::usercnt()
+int InspIRCd::UserCount()
 {
        return clientlist.size();
 }
 
 // this counts only registered users, so that the percentages in /MAP don't mess up when users are sitting in an unregistered state
-int InspIRCd::registered_usercount()
+int InspIRCd::RegisteredUserCount()
 {
        int c = 0;
 
@@ -338,7 +318,7 @@ int InspIRCd::registered_usercount()
        return c;
 }
 
-int InspIRCd::usercount_invisible()
+int InspIRCd::InvisibleUserCount()
 {
        int c = 0;
 
@@ -350,7 +330,7 @@ int InspIRCd::usercount_invisible()
        return c;
 }
 
-int InspIRCd::usercount_opers()
+int InspIRCd::OperCount()
 {
        int c = 0;
 
@@ -362,7 +342,7 @@ int InspIRCd::usercount_opers()
        return c;
 }
 
-int InspIRCd::usercount_unknown()
+int InspIRCd::UnregisteredUserCount()
 {
        int c = 0;
 
@@ -376,12 +356,12 @@ int InspIRCd::usercount_unknown()
        return c;
 }
 
-long InspIRCd::chancount()
+long InspIRCd::ChannelCount()
 {
        return chanlist.size();
 }
 
-long InspIRCd::local_count()
+long InspIRCd::LocalUserCount()
 {
        int c = 0;
 
@@ -446,6 +426,8 @@ void InspIRCd::OpenLog(char** argv, int argc)
                        printf("ERROR: Could not write to logfile %s, bailing!\n\n",Config->logpath.c_str());
                        Exit(ERROR);
                }
+
+               this->Logger = new FileLogger(this, Config->log_file);
                return;
        }
 
@@ -456,6 +438,8 @@ void InspIRCd::OpenLog(char** argv, int argc)
                printf("ERROR: Could not write to logfile %s, bailing!\n\n",Config->logpath.c_str());
                Exit(ERROR);
        }
+
+       this->Logger = new FileLogger(this, Config->log_file);
 }
 
 void InspIRCd::CheckRoot()
@@ -463,7 +447,7 @@ void InspIRCd::CheckRoot()
        if (geteuid() == 0)
        {
                printf("WARNING!!! You are running an irc server as ROOT!!! DO NOT DO THIS!!!\n\n");
-               ilog(this,DEFAULT,"Cant start as root");
+               this->Log(DEFAULT,"Cant start as root");
                Exit(ERROR);
        }
 }
@@ -473,7 +457,7 @@ void InspIRCd::CheckDie()
        if (*Config->DieValue)
        {
                printf("WARNING: %s\n\n",Config->DieValue);
-               ilog(this,DEFAULT,"Died because of <die> tag: %s",Config->DieValue);
+               this->Log(DEFAULT,"Died because of <die> tag: %s",Config->DieValue);
                Exit(ERROR);
        }
 }
@@ -492,12 +476,12 @@ void InspIRCd::LoadAllModules()
                
                if (!this->LoadModule(configToken))             
                {
-                       ilog(this,DEFAULT,"There was an error loading a module: %s", this->ModuleError());
+                       this->Log(DEFAULT,"There was an error loading a module: %s", this->ModuleError());
                        printf("\nThere was an error loading a module: %s\n\n",this->ModuleError());
                        Exit(ERROR);
                }
        }
        printf("\nA total of \033[1;32m%d\033[0m module%s been loaded.\n", this->ModCount+1, this->ModCount+1 == 1 ? " has" : "s have");
-       ilog(this,DEFAULT,"Total loaded modules: %d", this->ModCount+1);
+       this->Log(DEFAULT,"Total loaded modules: %d", this->ModCount+1);
 }