]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - src/s_log.c
ilog_error() replaces legacy report_error() craq
[irc/rqf/shadowircd.git] / src / s_log.c
index 4e81dcd69ce1ea9b14c0a62b398481e42a3bd56c..d0f59179e88ce4ecef3a09aff91c1236caefda6f 100644 (file)
@@ -1,8 +1,9 @@
 /*
- * ircd-ratbox: an advanced Internet Relay Chat Daemon(ircd).
+ * charybdis: an advanced Internet Relay Chat Daemon(ircd).
  *
  * Copyright (C) 2003 Lee H <lee@leeh.co.uk>
  * Copyright (C) 2003-2005 ircd-ratbox development team
+ * Copyright (C) 2008 William Pitcock <nenolod@sacredspiral.co.uk>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
  *
  * 1.Redistributions of source code must retain the above copyright notice,
  *   this list of conditions and the following disclaimer.
+ *
  * 2.Redistributions in binary form must reproduce the above copyright
  *   notice, this list of conditions and the following disclaimer in the
  *   documentation and/or other materials provided with the distribution.
+ *
  * 3.The name of the author may not be used to endorse or promote products
  *   derived from this software without specific prior written permission.
  *
@@ -118,10 +121,10 @@ ilog(ilogfile dest, const char *format, ...)
                return;
 
        va_start(args, format);
-       ircvsnprintf(buf, sizeof(buf), format, args);
+       rb_vsnprintf(buf, sizeof(buf), format, args);
        va_end(args);
 
-       ircsnprintf(buf2, sizeof(buf2), "%s %s\n", smalldate(), buf);
+       rb_snprintf(buf2, sizeof(buf2), "%s %s\n", smalldate(), buf);
 
        if(fputs(buf2, logfile) < 0)
        {
@@ -133,7 +136,7 @@ ilog(ilogfile dest, const char *format, ...)
 }
 
 static void
-_iprint(const char *domain, char *buf)
+_iprint(const char *domain, const char *buf)
 {
        if (domain == NULL || buf == NULL)
                return;
@@ -148,7 +151,7 @@ inotice(const char *format, ...)
        va_list args;
 
        va_start(args, format);
-       ircvsnprintf(buf, sizeof(buf), format, args);
+       rb_vsnprintf(buf, sizeof(buf), format, args);
        va_end(args);
 
        _iprint("notice", buf);
@@ -163,7 +166,7 @@ iwarn(const char *format, ...)
        va_list args;
 
        va_start(args, format);
-       ircvsnprintf(buf, sizeof(buf), format, args);
+       rb_vsnprintf(buf, sizeof(buf), format, args);
        va_end(args);
 
        _iprint("warning", buf);
@@ -178,7 +181,7 @@ ierror(const char *format, ...)
        va_list args;
 
        va_start(args, format);
-       ircvsnprintf(buf, sizeof(buf), format, args);
+       rb_vsnprintf(buf, sizeof(buf), format, args);
        va_end(args);
 
        _iprint("error", buf);
@@ -210,43 +213,21 @@ smalldate(void)
 {
        static char buf[MAX_DATE_STRING];
        struct tm *lt;
-       time_t ltime = CurrentTime;
+       time_t ltime = rb_current_time();
 
        lt = localtime(&ltime);
 
-       ircsnprintf(buf, sizeof(buf), "%d/%d/%d %02d.%02d",
+       rb_snprintf(buf, sizeof(buf), "%d/%d/%d %02d.%02d",
                    lt->tm_year + 1900, lt->tm_mon + 1,
                    lt->tm_mday, lt->tm_hour, lt->tm_min);
 
        return buf;
 }
 
-/*
- * report_error - report an error from an errno. 
- * Record error to log and also send a copy to all *LOCAL* opers online.
- *
- *        text        is a *format* string for outputing error. It must
- *                contain only two '%s', the first will be replaced
- *                by the sockhost from the client_p, and the latter will
- *                be taken from sys_errlist[errno].
- *
- *        client_p        if not NULL, is the *LOCAL* client associated with
- *                the error.
- *
- * Cannot use perror() within daemon. stderr is closed in
- * ircd and cannot be used. And, worse yet, it might have
- * been reassigned to a normal connection...
- * 
- * Actually stderr is still there IFF ircd was run with -s --Rodder
- */
-
 void
-report_error(const char *text, const char *who, const char *wholog, int error)
+ilog_error(const char *error)
 {
-       who = (who) ? who : "";
-       wholog = (wholog) ? wholog : "";
-
-       sendto_realops_snomask(SNO_DEBUG, L_ALL, text, who, strerror(error));
+       ilog(L_IOERROR, "%s: %d (%s)", buf, errno, strerror(errno));
 
-       ilog(L_IOERROR, text, wholog, strerror(error));
+       sendto_opers_snomask(SNO_DEBUG, L_ALL, "%s: %d (%s)", buf, errno, strerror(errno));
 }