syslog support for AC on linux (default)

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1953 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
driAn
2008-05-13 20:48:17 +00:00
parent b8cb9b64bc
commit 5619e04cba
3 changed files with 46 additions and 8 deletions
+42 -5
View File
@@ -39,16 +39,53 @@ struct filelog : log
};
struct syslog : log
#if !defined(WIN32) && !defined(__APPLE__)
#include <syslog.h>
#include <signal.h>
struct posixsyslog : log
{
int facility;
string ident;
posixsyslog(int facility, const char *ident)
{
this->facility = facility;
s_strcpy(this->ident, ident);
openlog(this->ident, LOG_NDELAY, this->facility);
}
~posixsyslog()
{
closelog();
}
virtual void writeline(int level, const char *msg, ...)
{
if(!enabled) return;
s_sprintfdv(sf, msg);
s_sprintfd(out)("%s\n", sf);
filtertext(out, out);
int l = (level==log::info ? LOG_INFO : ( level==log::warning ? LOG_WARNING : LOG_ERR));
syslog(l, out);
if(console) puts(out);
}
};
struct log *newlogger()
struct log *newlogger(const char *identity)
{
return new filelog("serverlog.txt");
s_sprintfd(id)("AssaultCube %s", identity);
return new posixsyslog(LOG_LOCAL6, id);
}
#else
struct log *newlogger(const char *identity)
{
s_sprintfd(file)("serverlog_%s.txt", identity);
return new filelog(file);
}
#endif