|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T l
Length: 5400 (0x1518) Types: TextFile Names: »log.c«
└─⟦9ae75bfbd⟧ Bits:30007242 EUUGD3: Starter Kit └─⟦f1ce22008⟧ »EurOpenD3/news/newsxd2.5.0.tar.Z« └─⟦caa165e81⟧ └─⟦this⟧ »log.c«
/* * #include <legal/bs.h> > > Copyright (c) 1989 Washington University in Saint Louis, Missouri and > Chris Myers. All rights reserved. > > Permission is hereby granted to copy, reproduce, redistribute or > otherwise use this software as long as: (1) there is no monetary > profit gained specifically from the use or reproduction of this > software, (2) it is not sold, rented, traded, or otherwise marketed, > (3) the above copyright notice and this paragraph is included > prominently in any copy made, and (4) that the name of the University > is not used to endorse or promote products derived from this software > without the specific prior written permission of the University. > THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR > IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED > WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. > */ #include "defs.h" /*************************************************************************/ /* FUNCTION : log */ /* PURPOSE : Log messages to syslog or a log file, as defined in */ /* newsxd.h. If debug or DEBUG is set, log to stderr. */ /* ARGUMENTS : Log priority, message to log, and message parameters */ /*************************************************************************/ void log(priority, message, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) /*VARARGS2*/ int priority; char *message, *p1, *p2, *p3, *p4, *p5, *p6, *p7, *p8, *p9, *p10; { static FILE *logfile = NULL; long clock; extern int errno; char buffer[30]; if ((debug > 0) || (DEBUG > 0)) { (void) fprintf(stderr, message, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); return; } #if defined(SYSLOG) syslog(priority, message, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); #endif #if defined(FAKESYSLOG) if ((logfile != NULL) && (CONFIGCHANGEDFILE)) { (void) fclose(logfile); logfile = NULL; CONFIGCHANGEDFILE = 0; } if (logfile == NULL) { logfile = fopen(fakelogfile, "a"); } if (logfile != NULL) { (void) time(&clock); (void) strcpy(buffer, ctime(&clock)); *index(buffer, '\n') = ' '; (void) fputs(buffer, logfile); (void) fprintf(logfile, message, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); (void) fflush(logfile); } #endif } /*************************************************************************/ /* FUNCTION : logerr */ /* PURPOSE : Log an error to syslog */ /* ARGUMENTS : Message to log, and message parameters */ /*************************************************************************/ void logerr(message, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) /*VARARGS1*/ char *message, *p1, *p2, *p3, *p4, *p5, *p6, *p7, *p8, *p9, *p10; { log(LOG_ERR, message, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); } /*************************************************************************/ /* FUNCTION : Dprintf */ /* PURPOSE : Do COPIOUS debugging logging */ /* ARGUMENTS : Message to log, and message parameters */ /*************************************************************************/ void Dprintf(message, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) /*VARARGS1*/ char *message, *p1, *p2, *p3, *p4, *p5, *p6, *p7, *p8, *p9, *p10; { if (DEBUG != 0) log(LOG_DEBUG, message, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); } /*************************************************************************/ /* FUNCTION : dprintf */ /* PURPOSE : Do normal debugging logging */ /* ARGUMENTS : Message to log, and message parameters */ /*************************************************************************/ void dprintf(message, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) /*VARARGS1*/ char *message, *p1, *p2, *p3, *p4, *p5, *p6, *p7, *p8, *p9, *p10; { if (debug != 0) log(LOG_DEBUG, message, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); } /*************************************************************************/ /* FUNCTION : debug_off */ /* PURPOSE : Increase debugging level during program execution */ /* ARGUMENTS : none */ /*************************************************************************/ void debug_on() { if (debug) DEBUG = -1; else debug = -1; log(LOG_INFO, "Debugging changed to debug %s, DEBUG %s\n", debug ? "On" : "Off", DEBUG ? "On" : "Off"); } /*************************************************************************/ /* FUNCTION : debug_off */ /* PURPOSE : Reduce debugging level during program execution */ /* ARGUMENTS : none */ /*************************************************************************/ void debug_off() { if (DEBUG) DEBUG = 0; else debug = 0; log(LOG_INFO, "Debugging changed to debug %s, DEBUG %s\n", debug ? "On" : "Off", DEBUG ? "On" : "Off"); }