]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
do_log -> static void InspIRCd::Log() (with vararg and std::string variants)
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Wed, 9 Aug 2006 13:19:41 +0000 (13:19 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Wed, 9 Aug 2006 13:19:41 +0000 (13:19 +0000)
The #define for this still exists, but maybe should be phased out?

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4809 e03df62e-2008-0410-955e-edbf42e46eb7

include/helperfuncs.h
include/inspircd.h
include/u_listmode.h
src/helperfuncs.cpp
src/modules/m_cgiirc.cpp
src/modules/m_operlog.cpp
src/modules/m_remove.cpp
src/modules/m_testcommand.cpp
src/modules/m_watch.cpp

index e094b1a0e2c6b5c9d2d5e86b01d83cc27cde59f9..e5b56305107dd9a4730b7f66ca334b0a4d8fac13 100644 (file)
@@ -43,7 +43,7 @@
  */
 #define STRINGIFY2(x) #x
 #define STRINGIFY(x) STRINGIFY2(x) 
-#define log(l, x, args...) do_log(l, __FILE__ ":" STRINGIFY(__LINE__) ": " x, ##args)
+#define log(l, x, args...) InspIRCd::Log(l, __FILE__ ":" STRINGIFY(__LINE__) ": " x, ##args)
 
 void do_log(int level, const char *text, ...);
 void readfile(file_cache &F, const char* fname);
index 0b2a2830d3ae069e1fc6f9698d2f02dadfc2be04..91d57f75d896e31ff741dbab7a6614aea270bca4 100644 (file)
@@ -43,7 +43,7 @@
  */
 #define IS_SINGLE(x,y) ( (*x == y) && (*(x+1) == 0) )
 
-#define DELETE(x) { do_log(DEBUG,"%s:%d: delete()",__FILE__,__LINE__); if (x) { delete x; x = NULL; } else log(DEBUG,"Attempt to delete NULL pointer!"); }
+#define DELETE(x) { InspIRCd::Log(DEBUG,"%s:%d: delete()",__FILE__,__LINE__); if (x) { delete x; x = NULL; } else InspIRCd::Log(DEBUG,"Attempt to delete NULL pointer!"); }
 
 template<typename T> inline std::string ConvToStr(const T &in)
 {
@@ -114,6 +114,8 @@ class InspIRCd : public classbase
        bool UnloadModule(const char* filename);
        InspIRCd(int argc, char** argv);
        void DoOneIteration(bool process_module_sockets);
+       static void Log(int level, const char* text, ...);
+       static void Log(int level, const std::string &text);
        int Run();
 };
 
index b3958caa2f7d5a352a83c15b4171cf90fd72c34b..45b04c158587dc031776f455e77cdc7bab0f82ed 100644 (file)
@@ -9,6 +9,7 @@
 #include "channels.h"
 #include "modules.h"
 #include "helperfuncs.h"
+#include "inspircd.h"
 
 /* $ModDesc: Provides support for easily creating listmodes, stores the time set, the user, and a parameter. */
 
index b25370df698e4fa0df12cc6c9fbf71a252a89dc6..97cb68f33e0afd0e0e927583063cfd2495cb0c4e 100644 (file)
@@ -65,11 +65,20 @@ static time_t LAST = 0;
  *  Write a line of text `text' to the logfile (and stdout, if in nofork) if the level `level'
  *  is greater than the configured loglevel.
  */
-void do_log(int level, const char *text, ...)
+void InspIRCd::Log(int level, const char* text, ...)
 {
        va_list argsPtr;
        char textbuffer[MAXBUF];
 
+       va_start(argsPtr, text);
+       vsnprintf(textbuffer, MAXBUF, text, argsPtr);
+       va_end(argsPtr);
+
+       InspIRCd::Log(level, std::string(textbuffer));
+}
+
+void InspIRCd::Log(int level, const std::string &text)
+{
        if (!ServerInstance || !ServerInstance->Config)
                return;
 
@@ -86,22 +95,15 @@ void do_log(int level, const char *text, ...)
                LAST = TIME;
        }
 
-       if (ServerInstance->Config->log_file)
+       if (ServerInstance->Config->log_file && ServerInstance->Config->writelog)
        {
-               va_start(argsPtr, text);
-               vsnprintf(textbuffer, MAXBUF, text, argsPtr);
-               va_end(argsPtr);
-
-               if (ServerInstance->Config->writelog)
-               {
-                       fprintf(ServerInstance->Config->log_file,"%s %s\n",TIMESTR,textbuffer);
-                       fflush(ServerInstance->Config->log_file);
-               }
+               fprintf(ServerInstance->Config->log_file,"%s %s\n",TIMESTR,text.c_str());
+               fflush(ServerInstance->Config->log_file);
        }
-       
+
        if (ServerInstance->Config->nofork)
        {
-               printf("%s %s\n", TIMESTR, textbuffer);
+               printf("%s %s\n", TIMESTR, text.c_str());
        }
 }
 
index 3a1bccaf730602494caa271da8a95a9c992f9bb4..4fcb0be13be829792c25dab38969f17d35577f43 100644 (file)
@@ -25,6 +25,7 @@
 #include "modules.h"
 #include "helperfuncs.h"
 #include "dns.h"
+#include "inspircd.h"
 
 /* $ModDesc: Change user's hosts connecting from known CGI:IRC hosts */
 
index 8188c49b18289813b7f640215fe3e4a6e22fb51d..4881eefa021ffa0ac7d896628036b5be23f02e0d 100644 (file)
@@ -20,7 +20,7 @@ using namespace std;
 #include "channels.h"
 #include "modules.h"
 #include "helperfuncs.h"
-#include "message.h"
+#include "inspircd.h"
 #include <vector>
 
 /* $ModDesc: A module which logs all oper commands to the ircd log at default loglevel. */
index a9c478a8914c097de705d710b3a41bbbf83f66ab..a5657f604d3ec178f9e29cf0a65f7ded3795e551 100644 (file)
@@ -7,6 +7,7 @@
 #include "channels.h"
 #include "modules.h"
 #include "helperfuncs.h"
+#include "inspircd.h"
 
 /* $ModDesc: Provides a /remove command, this is mostly an alternative to /kick, except makes users appear to have parted the channel */
 
index 6f517e8ced9c8582ae8a3a48b0ae57495c293a9e..9b3509f8d277c67d175aeafd291c722179dab995 100644 (file)
@@ -22,6 +22,7 @@ using namespace std;
 #include "modules.h"
 #include "helperfuncs.h"
 #include "dns.h"
+#include "inspircd.h"
 
 /* $ModDesc: Povides a proof-of-concept test /WOOT command */
 
index 888827cfa79e50a27ad752302569be9e1d0fd53c..2ba9c9afb1bc1c2964be5d830d55a85d9c3013d5 100644 (file)
@@ -24,6 +24,7 @@ using namespace std;
 #include "modules.h"
 #include "helperfuncs.h"
 #include "hashcomp.h"
+#include "inspircd.h"
 
 /* $ModDesc: Provides support for the /watch command */