]> jfr.im git - solanum.git/blobdiff - ircd/logger.c
support RSFNC indicating type of FNC (e.g. FORCE vs REGAIN) (#406)
[solanum.git] / ircd / logger.c
index e7f14f61f6b6263673c7ba97e6ff7f98befcdf1c..44294b19904c4907966917bcb85a32a2dcf1370c 100644 (file)
@@ -1,9 +1,9 @@
 /*
- * charybdis: an advanced Internet Relay Chat Daemon(ircd).
+ * Solanum: a slightly advanced 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>
+ * Copyright (C) 2008 Ariadne Conill <ariadne@dereferenced.org>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -30,8 +30,6 @@
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
- *
- * $Id: s_log.c 3209 2007-02-11 16:54:43Z jilles $
  */
 
 #include "stdinc.h"
@@ -84,7 +82,7 @@ verify_logfile_access(const char *filename)
 
        if(access(dirname, F_OK) == -1)
        {
-               rb_snprintf(buf, sizeof(buf), "WARNING: Unable to access logfile %s - parent directory %s does not exist", filename, dirname);
+               snprintf(buf, sizeof(buf), "WARNING: Unable to access logfile %s - parent directory %s does not exist", filename, dirname);
                if(testing_conf || server_state_foreground)
                        fprintf(stderr, "%s\n", buf);
                sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s", buf);
@@ -95,7 +93,7 @@ verify_logfile_access(const char *filename)
        {
                if(access(dirname, W_OK) == -1)
                {
-                       rb_snprintf(buf, sizeof(buf), "WARNING: Unable to access logfile %s - access to parent directory %s failed: %s",
+                       snprintf(buf, sizeof(buf), "WARNING: Unable to access logfile %s - access to parent directory %s failed: %s",
                                    filename, dirname, strerror(errno));
                        if(testing_conf || server_state_foreground)
                                fprintf(stderr, "%s\n", buf);
@@ -106,7 +104,7 @@ verify_logfile_access(const char *filename)
 
        if(access(filename, W_OK) == -1)
        {
-               rb_snprintf(buf, sizeof(buf), "WARNING: Access denied for logfile %s: %s", filename, strerror(errno));
+               snprintf(buf, sizeof(buf), "WARNING: Access denied for logfile %s: %s", filename, strerror(errno));
                if(testing_conf || server_state_foreground)
                        fprintf(stderr, "%s\n", buf);
                sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s", buf);
@@ -170,17 +168,17 @@ ilog(ilogfile dest, const char *format, ...)
 {
        FILE *logfile = *log_table[dest].logfile;
        char buf[BUFSIZE];
-       char buf2[BUFSIZE];
+       char buf2[MAX_DATE_STRING + 1 + BUFSIZE + 1];
        va_list args;
 
        if(logfile == NULL)
                return;
 
        va_start(args, format);
-       rb_vsnprintf(buf, sizeof(buf), format, args);
+       vsnprintf(buf, sizeof(buf), format, args);
        va_end(args);
 
-       rb_snprintf(buf2, sizeof(buf2), "%s %s\n",
+       snprintf(buf2, sizeof(buf2), "%s %s\n",
                        smalldate(rb_current_time()), buf);
 
        if(fputs(buf2, logfile) < 0)
@@ -202,6 +200,23 @@ _iprint(const char *domain, const char *buf)
        fprintf(stderr, "%8s: %s\n", domain, buf);
 }
 
+void
+idebug(const char *format, ...)
+{
+#ifndef NDEBUG
+       char buf[BUFSIZE];
+       va_list args;
+
+       va_start(args, format);
+       vsnprintf(buf, sizeof(buf), format, args);
+       va_end(args);
+
+       _iprint("debug", buf);
+
+       ilog(L_MAIN, "%s", buf);
+#endif
+}
+
 void
 inotice(const char *format, ...)
 {
@@ -209,7 +224,7 @@ inotice(const char *format, ...)
        va_list args;
 
        va_start(args, format);
-       rb_vsnprintf(buf, sizeof(buf), format, args);
+       vsnprintf(buf, sizeof(buf), format, args);
        va_end(args);
 
        _iprint("notice", buf);
@@ -224,7 +239,7 @@ iwarn(const char *format, ...)
        va_list args;
 
        va_start(args, format);
-       rb_vsnprintf(buf, sizeof(buf), format, args);
+       vsnprintf(buf, sizeof(buf), format, args);
        va_end(args);
 
        _iprint("warning", buf);
@@ -239,7 +254,7 @@ ierror(const char *format, ...)
        va_list args;
 
        va_start(args, format);
-       rb_vsnprintf(buf, sizeof(buf), format, args);
+       vsnprintf(buf, sizeof(buf), format, args);
        va_end(args);
 
        _iprint("error", buf);
@@ -274,7 +289,7 @@ smalldate(time_t ltime)
 
        lt = localtime(&ltime);
 
-       rb_snprintf(buf, sizeof(buf), "%d/%d/%d %02d.%02d",
+       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);