*/
#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);
*/
#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)
{
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();
};
* 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;
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());
}
}