# # Patch name: syslog # Patch version: 1 # Author's name: Jonas Oberg # Author's email: jonas@coyote.eu.org # Version of PennMUSH: 1.6.10pl0 # Date patch made: 97/03/24 # Author is willing to support (yes/no): yes # Patch format: unified diff # # # This is a contributed PennMUSH patch. Its use is subject to the # same restrictions found in PennMUSH's hdrs/copyrite.h file. # # No warranty is given for this patch. It is not necessarily going # to work on your system, with any version of PennMUSH other than # the one above, etc. # # If the author given above was willing to support the patch, you # should write to the author if you have any questions or problems. Do # *NOT* send email messages to Javelin or any PennMUSH mailing list about # this patch! # # Below this line is the author's description of the patch, # followed by the patch itself. If the patch is in context diff # format, you'll probably apply it by typing: patch < patchfile # in your top-level MUSH directory, unless instructed otherwise # below. # This is a small patch for log.c that makes PennMUSH able to log via syslog instead of standard file handles. The facility to use can be defined via the SYSLOG_PGM definition. LOG_LOCAL7 is the default facility. The different logs are written with the following priorities: errorlog: ERROR, command: DEBUG, wizard: NOTICE, connect: INFO, trace: DEBUG, checkpoint: DEBUG, huh's: NOTICE --- dune.h.dist Thu Nov 14 18:04:17 1996 +++ dune.h Mon Mar 24 00:11:14 1997 @@ -422,5 +422,19 @@ /* If defined, DARK wizards don't trigger AENTER/ALEAVE as they move around */ /* #define WIZ_NOAENTER /* */ +/* If defined, the MUSH will log things via syslog instead of normal files. */ +#define SYSLOG /* */ + +/* This defines which facility to use when logging via syslog. You could, + for example tell it to log everything as if it came from the kernel by + specifying LOG_KERN, though I don't recommed it :) + LOG_LOCAL7 should be suitable for mosts setups. Your syslog.conf line + could read something like this: + + local7.* /var/adm/mush + + to log everything from the MUSH to /var/log/mush. +*/ +#define SYSLOG_PGM LOG_LOCAL7 /* */ #endif /* __DUNE_H */ --- src/log.c.orig Mon Mar 24 00:03:25 1997 +++ src/log.c Mon Mar 24 00:05:27 1997 @@ -31,6 +31,10 @@ #include "intrface.h" #include "confmagic.h" +#ifdef SYSLOG +#include +#endif + char *quick_unparse _((dbref object)); void start_log _((FILE ** fp, const char *filename)); void end_log _((FILE * fp)); @@ -66,22 +70,31 @@ FILE **fp; const char *filename; { +#ifndef SYSLOG *fp = fopen(filename, "w"); if (*fp == NULL) { fprintf(stderr, "WARNING: cannot open log %s\n", filename); *fp = stderr; } +#else + openlog("MUSH", 0, SYSLOG_PGM); +#endif + } void end_log(fp) FILE *fp; { +#ifndef SYSLOG if (fp != stderr) { fprintf(fp, "END OF LOG.\n"); fflush(fp); fclose(fp); } +#else + closelog(); +#endif } #ifdef I_STDARG @@ -104,6 +117,10 @@ char tbuf1[BUFFER_LEN + 50]; va_list args; FILE *f = NULL; +#ifdef SYSLOG + int pri; +#endif + #ifndef I_STDARG char *fmt; @@ -115,6 +132,7 @@ (void) vsprintf(tbuf1, fmt, args); va_end(args); +#ifndef SYSLOG time(&tt); ttm = localtime(&tt); sprintf(timebuf, "%d%d/%d%d %d%d:%d%d:%d%d", @@ -154,6 +172,38 @@ } fprintf(f, "%s %s\n", timebuf, tbuf1); fflush(f); +#else /* SYSLOG */ + switch (logtype) { + case LT_ERR: + pri = LOG_ERR; + break; + case LT_CMD: + pri = LOG_DEBUG; + break; + case LT_WIZ: + pri = LOG_NOTICE; + break; + case LT_CONN: + pri = LOG_INFO; + break; + case LT_TRACE: + pri = LOG_DEBUG; + break; + case LT_RPAGE: + break; + case LT_CHECK: + pri = LOG_DEBUG; + break; + case LT_HUH: + pri = LOG_NOTICE; + break; + default: + pri = LOG_DEBUG; + break; + } + syslog(pri, tbuf1); +#endif + } #ifdef I_STDARG