Skip to content
Permalink
Browse files

Use syslog for logging (#1309)

* Support logging through syslog

* Add log levels to some logging.

* Add changelog entry.
  • Loading branch information...
shawnw committed Jul 30, 2019
1 parent 7c8ad37 commit bdd0d188d5385cf073387a7c7a9e4223e9a105b6
Showing with 329 additions and 181 deletions.
  1. +1 −0 CHANGES.188.md
  2. +4 −0 config.h.in
  3. +2 −2 configure
  4. +2 −2 configure.in
  5. +3 −0 game/mushcnf.dst
  6. +8 −7 hdrs/conf.h
  7. +18 −0 hdrs/log.h
  8. +140 −109 src/bsd.c
  9. +11 −6 src/conf.c
  10. +32 −28 src/game.c
  11. +97 −19 src/log.c
  12. +11 −8 src/memcheck.c
@@ -53,6 +53,7 @@ Minor Changes
* @SOCKSET now has a NOQUOTA option which causes that socket to be given the max command input quota per refresh. [MT]
* --disable-socket-quota is now preserved across reboots. [MT]
* Improved detection of an already running game. [SW]
* Support logging through the OS syslog facility. [SW]
Softcode
--------
@@ -77,6 +77,8 @@

#undef HAVE_FENV_H

#undef HAVE_SYSLOG_H

/* Libraries */

#undef HAVE_MYSQL
@@ -336,6 +338,8 @@ typedef bool _Bool;

#undef HAVE_PTHREAD_ATFORK

#undef HAVE_SYSLOG

/* Bunch of sqlite3 stuff */

#undef HAVE_FDATASYNC
@@ -7146,7 +7146,7 @@ fi

done

for ac_header in event2/event.h event2/dns.h fenv.h sys/param.h
for ac_header in event2/event.h event2/dns.h fenv.h sys/param.h syslog.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
@@ -10334,7 +10334,7 @@ _ACEOF
fi
done

for ac_func in pread pwrite eventfd pledge pipe2
for ac_func in pread pwrite eventfd pledge pipe2 syslog
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
@@ -145,7 +145,7 @@ AC_CHECK_HEADERS([sys/stat.h sys/time.h sys/types.h sys/eventfd.h])
AC_CHECK_HEADERS([sys/socket.h arpa/inet.h libintl.h netdb.h netinet/tcp.h])
AC_CHECK_HEADERS([netinet/in.h sys/un.h sys/resource.h sys/event.h sys/uio.h])
AC_CHECK_HEADERS([poll.h sys/select.h sys/inotify.h langinfo.h crypt.h])
AC_CHECK_HEADERS([event2/event.h event2/dns.h fenv.h sys/param.h])
AC_CHECK_HEADERS([event2/event.h event2/dns.h fenv.h sys/param.h syslog.h])
AC_CHECK_HEADERS([sys/prctl.h byteswap.h endian.h sys/endian.h pthread.h])
AC_CHECK_HEADERS([sys/ucred.h sys/file.h], [], [], [
AC_INCLUDES_DEFAULT
@@ -264,7 +264,7 @@ AC_CHECK_FUNCS([cbrt log2 lrint imaxdiv hypot])
AC_CHECK_FUNCS([getuid geteuid seteuid getpriority setpriority])
AC_CHECK_FUNCS([socketpair sigaction sigprocmask writev])
AC_CHECK_FUNCS([fcntl flock poll kqueue inotify_init1])
AC_CHECK_FUNCS([pread pwrite eventfd pledge pipe2])
AC_CHECK_FUNCS([pread pwrite eventfd pledge pipe2 syslog])
AC_CHECK_FUNCS([fetestexcept feclearexcept])
AX_FUNC_POSIX_MEMALIGN

@@ -600,6 +600,9 @@ colors_file txt/colors.json
### MUSH.
###

# If true, also log messages to the system syslog service.
use_syslog no

# Filename to log important messages (startups, errors, shutdowns)
error_log log/netmush.log

@@ -230,13 +230,14 @@ struct options_table {
files */
char guest_file[2][FILE_PATH_LEN]; /**< Names of text and html guest files */
char who_file[2][FILE_PATH_LEN]; /**< Names of text and html who files */
char index_html[FILE_PATH_LEN]; /**< Name of the default HTTP landing page */
int log_commands; /**< Should we log all commands? */
int log_forces; /**< Should we log force commands? */
int support_pueblo; /**< Should the MUSH send Pueblo tags? */
int login_allow; /**< Are mortals allowed to log in? */
int guest_allow; /**< Are guests allowed to log in? */
int create_allow; /**< Can new players be created? */
char index_html[FILE_PATH_LEN]; /**< Name of the default HTTP landing page */
int use_syslog; /**< Should we also log to syslog? */
int log_commands; /**< Should we log all commands? */
int log_forces; /**< Should we log force commands? */
int support_pueblo; /**< Should the MUSH send Pueblo tags? */
int login_allow; /**< Are mortals allowed to log in? */
int guest_allow; /**< Are guests allowed to log in? */
int create_allow; /**< Can new players be created? */
int reverse_shs; /**< Should the SHS routines assume little-endian byte order?
*/
char player_flags[BUFFER_LEN]; /**< Space-separated list of flags to set on
@@ -8,6 +8,7 @@
#define LOG_H

#include <stdio.h>
#include <stdarg.h>
#include "bufferq.h"
#include "mushtype.h"

@@ -22,6 +23,18 @@ enum log_type {
LT_HUH /**< Logs of huh_command's */
};

/** Log levels. Used for syslog logging. */
enum log_level {
MLOG_EMERG, /**< MUSH is unusable */
MLOG_ALERT, /**< action must be taken immediately */
MLOG_CRIT, /**< critical conditions */
MLOG_ERR, /**< error conditions */
MLOG_WARNING, /**< warning conditions */
MLOG_NOTICE, /**< normal but significant condition */
MLOG_INFO, /**< informational message */
MLOG_DEBUG /**< debug-level message */
};

/** A logfile stream */
struct log_stream {
enum log_type type; /**< Log type */
@@ -41,6 +54,11 @@ void reopen_logs(void);
void WIN32_CDECL do_log(enum log_type logtype, dbref player, dbref object,
const char *fmt, ...)
__attribute__((__format__(__printf__, 4, 5)));
void do_rawlog_vlvl(enum log_type logtype, enum log_level loglevel,
const char *fmt, va_list args);
void WIN32_CDECL do_rawlog_lvl(enum log_type logtype, enum log_level loglevel,
const char *fmt, ...)
__attribute__((__format__(__printf__, 3, 4)));
void WIN32_CDECL do_rawlog(enum log_type logtype, const char *fmt, ...)
__attribute__((__format__(__printf__, 2, 3)));

0 comments on commit bdd0d18

Please sign in to comment.
You can’t perform that action at this time.