AC_CHECK_TYPES(long long)
AC_CHECK_HEADERS(ctype.h pwd.h stdlib.h string.h strings.h sys/time.h sys/mman.h)
+AC_CHECK_HEADERS(syslog.h)
AC_CHECK_HEADERS(termios.h)
AC_CHECK_FUNCS(gethostname)
AC_CHECK_FUNCS(setenv)
AC_CHECK_FUNCS(strndup)
AC_CHECK_FUNCS(strtok_r)
+AC_CHECK_FUNCS(syslog)
AC_CHECK_FUNCS(unsetenv)
AC_CHECK_FUNCS(utimes)
If set to a file path, ccache will write information on what it is doing to
the specified file. This is useful for tracking down problems.
++
+If set to "syslog", then ccache will log using syslog() instead of a file.
+Then you can use syslogd configuration to filter into a file, example:
++
+-------------------------------------------------------------------------------
+# log ccache to file
+:programname, isequal, "ccache" /var/log/ccache
+# remove from syslog
+& ~
+-------------------------------------------------------------------------------
*max_files* (*CCACHE_MAXFILES*)::
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
+#ifdef HAVE_SYSLOG_H
+#include <syslog.h>
+#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
// Destination for conf->log_file.
static FILE *logfile;
+// Whether to use syslog() instead.
+static bool use_syslog;
+
// Buffer used for logs in conf->debug mode.
static char *debug_log_buffer;
{
extern struct conf *conf;
- if (debug_log_buffer || logfile) {
+ if (debug_log_buffer || logfile || use_syslog) {
return true;
}
assert(conf);
if (str_eq(conf->log_file, "")) {
return conf->debug;
}
+#ifdef HAVE_SYSLOG
+ if (str_eq(conf->log_file, "syslog")) {
+ use_syslog = true;
+ openlog("ccache", LOG_PID, LOG_USER);
+ return true;
+ }
+#endif
logfile = fopen(conf->log_file, "a");
if (logfile) {
#ifndef _WIN32
if (logfile) {
fputs(prefix, logfile);
}
+#ifdef HAVE_SYSLOG
+ if (use_syslog) {
+ // prefix information will be added by syslog
+ }
+#endif
if (debug_log_buffer) {
append_to_debug_log(prefix, strlen(prefix));
}
warn_log_fail();
}
}
+#ifdef HAVE_SYSLOG
+ if (use_syslog) {
+ vsyslog(LOG_DEBUG, format, ap);
+ }
+#endif
if (debug_log_buffer) {
char buf[8192];
int len = vsnprintf(buf, sizeof(buf), format, aq);
warn_log_fail();
}
}
+#ifdef HAVE_SYSLOG
+ if (use_syslog) {
+ char *s = format_command(argv);
+ syslog(LOG_DEBUG, "%s", s);
+ free(s);
+ }
+#endif
if (debug_log_buffer) {
append_to_debug_log(prefix, strlen(prefix));
char *s = format_command(argv);