Skip to content

Commit

Permalink
Use syslog for logging (#1309)
Browse files Browse the repository at this point in the history
* 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 bdd0d18
Show file tree
Hide file tree
Showing 12 changed files with 329 additions and 181 deletions.
1 change: 1 addition & 0 deletions CHANGES.188.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -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] * @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] * --disable-socket-quota is now preserved across reboots. [MT]
* Improved detection of an already running game. [SW] * Improved detection of an already running game. [SW]
* Support logging through the OS syslog facility. [SW]


Softcode Softcode
-------- --------
Expand Down
4 changes: 4 additions & 0 deletions config.h.in
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@


#undef HAVE_FENV_H #undef HAVE_FENV_H


#undef HAVE_SYSLOG_H

/* Libraries */ /* Libraries */


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


#undef HAVE_PTHREAD_ATFORK #undef HAVE_PTHREAD_ATFORK


#undef HAVE_SYSLOG

/* Bunch of sqlite3 stuff */ /* Bunch of sqlite3 stuff */


#undef HAVE_FDATASYNC #undef HAVE_FDATASYNC
Expand Down
4 changes: 2 additions & 2 deletions configure
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7146,7 +7146,7 @@ fi


done 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 : do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` 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" ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
Expand Down Expand Up @@ -10334,7 +10334,7 @@ _ACEOF
fi fi
done done


for ac_func in pread pwrite eventfd pledge pipe2 for ac_func in pread pwrite eventfd pledge pipe2 syslog
do : do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
Expand Down
4 changes: 2 additions & 2 deletions configure.in
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -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([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([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([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/prctl.h byteswap.h endian.h sys/endian.h pthread.h])
AC_CHECK_HEADERS([sys/ucred.h sys/file.h], [], [], [ AC_CHECK_HEADERS([sys/ucred.h sys/file.h], [], [], [
AC_INCLUDES_DEFAULT AC_INCLUDES_DEFAULT
Expand Down Expand Up @@ -264,7 +264,7 @@ AC_CHECK_FUNCS([cbrt log2 lrint imaxdiv hypot])
AC_CHECK_FUNCS([getuid geteuid seteuid getpriority setpriority]) AC_CHECK_FUNCS([getuid geteuid seteuid getpriority setpriority])
AC_CHECK_FUNCS([socketpair sigaction sigprocmask writev]) AC_CHECK_FUNCS([socketpair sigaction sigprocmask writev])
AC_CHECK_FUNCS([fcntl flock poll kqueue inotify_init1]) 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]) AC_CHECK_FUNCS([fetestexcept feclearexcept])
AX_FUNC_POSIX_MEMALIGN AX_FUNC_POSIX_MEMALIGN


Expand Down
3 changes: 3 additions & 0 deletions game/mushcnf.dst
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -600,6 +600,9 @@ colors_file txt/colors.json
### MUSH. ### MUSH.
### ###


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

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


Expand Down
15 changes: 8 additions & 7 deletions hdrs/conf.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -230,13 +230,14 @@ struct options_table {
files */ files */
char guest_file[2][FILE_PATH_LEN]; /**< Names of text and html guest 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 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 */ char index_html[FILE_PATH_LEN]; /**< Name of the default HTTP landing page */
int log_commands; /**< Should we log all commands? */ int use_syslog; /**< Should we also log to syslog? */
int log_forces; /**< Should we log force commands? */ int log_commands; /**< Should we log all commands? */
int support_pueblo; /**< Should the MUSH send Pueblo tags? */ int log_forces; /**< Should we log force commands? */
int login_allow; /**< Are mortals allowed to log in? */ int support_pueblo; /**< Should the MUSH send Pueblo tags? */
int guest_allow; /**< Are guests allowed to log in? */ int login_allow; /**< Are mortals allowed to log in? */
int create_allow; /**< Can new players be created? */ 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? 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 char player_flags[BUFFER_LEN]; /**< Space-separated list of flags to set on
Expand Down
18 changes: 18 additions & 0 deletions hdrs/log.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#define LOG_H #define LOG_H


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


Expand All @@ -22,6 +23,18 @@ enum log_type {
LT_HUH /**< Logs of huh_command's */ 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 */ /** A logfile stream */
struct log_stream { struct log_stream {
enum log_type type; /**< Log type */ enum log_type type; /**< Log type */
Expand All @@ -41,6 +54,11 @@ void reopen_logs(void);
void WIN32_CDECL do_log(enum log_type logtype, dbref player, dbref object, void WIN32_CDECL do_log(enum log_type logtype, dbref player, dbref object,
const char *fmt, ...) const char *fmt, ...)
__attribute__((__format__(__printf__, 4, 5))); __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, ...) void WIN32_CDECL do_rawlog(enum log_type logtype, const char *fmt, ...)
__attribute__((__format__(__printf__, 2, 3))); __attribute__((__format__(__printf__, 2, 3)));


Expand Down
Loading

0 comments on commit bdd0d18

Please sign in to comment.