Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Do not generate sgLog.c
... but enable syslog when USE_SYSLOG is defined.
  • Loading branch information
andihofmeister committed May 1, 2012
1 parent 7570ca8 commit 554795d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 31 deletions.
7 changes: 1 addition & 6 deletions configure
Expand Up @@ -650,8 +650,6 @@ MYSQLLINE
YACCLINE2
YACCLINE
LOGFAC
NOSYSLOG2
NOSYSLOG1
NOLOG2
NOLOG1
sg_dbhome
Expand Down Expand Up @@ -4516,8 +4514,6 @@ cat >>confdefs.h <<\_ACEOF
_ACEOF

else
NOSYSLOG1="/* syslog not configured"
NOSYSLOG2="*/"
echo "checking syslog for logging... no"
fi

Expand Down Expand Up @@ -6383,7 +6379,7 @@ TESTDIR="`pwd`/test"



ac_config_files="$ac_config_files Makefile src/Makefile src/main.c src/sgLog.c src/sgDiv.c src/sg.h src/sg.y test/Makefile test/test1.conf test/test2.conf samples/Makefile samples/sample.conf samples/squidGuard.cgi samples/squidGuard-simple.cgi samples/squidGuard-simple-de.cgi contrib/Makefile contrib/squidGuardRobot/squidGuardRobot contrib/sgclean/sgclean contrib/hostbyname/hostbyname"
ac_config_files="$ac_config_files Makefile src/Makefile src/main.c src/sgDiv.c src/sg.h src/sg.y test/Makefile test/test1.conf test/test2.conf samples/Makefile samples/sample.conf samples/squidGuard.cgi samples/squidGuard-simple.cgi samples/squidGuard-simple-de.cgi contrib/Makefile contrib/squidGuardRobot/squidGuardRobot contrib/sgclean/sgclean contrib/hostbyname/hostbyname"

cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
Expand Down Expand Up @@ -6983,7 +6979,6 @@ do
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
"src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
"src/main.c") CONFIG_FILES="$CONFIG_FILES src/main.c" ;;
"src/sgLog.c") CONFIG_FILES="$CONFIG_FILES src/sgLog.c" ;;
"src/sgDiv.c") CONFIG_FILES="$CONFIG_FILES src/sgDiv.c" ;;
"src/sg.h") CONFIG_FILES="$CONFIG_FILES src/sg.h" ;;
"src/sg.y") CONFIG_FILES="$CONFIG_FILES src/sg.y" ;;
Expand Down
6 changes: 1 addition & 5 deletions configure.in
Expand Up @@ -190,8 +190,6 @@ echo "checking syslog for logging... yes"
LOGFAC="$syslog_facility"
AC_DEFINE(USE_SYSLOG, 1, [Defined if SYSLOG support should be compiled])
else
NOSYSLOG1="/* syslog not configured"
NOSYSLOG2="*/"
echo "checking syslog for logging... no"
fi

Expand Down Expand Up @@ -483,8 +481,6 @@ AC_SUBST(sg_logdir)
AC_SUBST(sg_dbhome)
AC_SUBST(NOLOG1)
AC_SUBST(NOLOG2)
AC_SUBST(NOSYSLOG1)
AC_SUBST(NOSYSLOG2)
AC_SUBST(LOGFAC)
AC_SUBST(YACCLINE)
AC_SUBST(YACCLINE2)
Expand All @@ -501,4 +497,4 @@ AC_SUBST(SQUIDGUARDROBOTUA)
AC_SUBST(ROBOTEXCEPTIONS)
AC_SUBST(BLACKLISTS)

AC_OUTPUT(Makefile src/Makefile src/main.c src/sgLog.c src/sgDiv.c src/sg.h src/sg.y test/Makefile test/test1.conf test/test2.conf samples/Makefile samples/sample.conf samples/squidGuard.cgi samples/squidGuard-simple.cgi samples/squidGuard-simple-de.cgi contrib/Makefile contrib/squidGuardRobot/squidGuardRobot contrib/sgclean/sgclean contrib/hostbyname/hostbyname)
AC_OUTPUT(Makefile src/Makefile src/main.c src/sgDiv.c src/sg.h src/sg.y test/Makefile test/test1.conf test/test2.conf samples/Makefile samples/sample.conf samples/squidGuard.cgi samples/squidGuard-simple.cgi samples/squidGuard-simple-de.cgi contrib/Makefile contrib/squidGuardRobot/squidGuardRobot contrib/sgclean/sgclean contrib/hostbyname/hostbyname)
61 changes: 41 additions & 20 deletions src/sgLog.c.in → src/sgLog.c
Expand Up @@ -22,6 +22,7 @@ extern int globalDebug; /* from main.c */
extern int globalPid; /* from main.c */
extern char *globalLogDir; /* from main.c */
extern struct LogFileStat *globalErrorLog;

#ifdef USE_SYSLOG
#include <syslog.h>
#endif
Expand Down Expand Up @@ -78,11 +79,15 @@ void sgLogDebug(char *format, ...)
if (vsnprintf(msg, MAX_BUF, format, ap) > (MAX_BUF - 1))
sgLog(globalErrorLog, "FATAL: overflow in vsnprintf (sgLogError): %s", strerror(errno));
va_end(ap);
@NOSYSLOG1@ if (globalSyslog == 1) {
#ifdef USE_SYSLOG
if (globalSyslog == 1) {
syslog(LOG_DEBUG, "%s\n", msg);
} else { @NOSYSLOG2@
sgLog(globalErrorLog, "%s", msg);
@NOSYSLOG1@ } @NOSYSLOG2@
} else {
sgLog(globalErrorLog, "%s", msg);
}
#else
sgLog(globalErrorLog, "%s", msg);
#endif
}


Expand All @@ -94,11 +99,15 @@ void sgLogNotice(char *format, ...)
if (vsnprintf(msg, MAX_BUF, format, ap) > (MAX_BUF - 1))
sgLog(globalErrorLog, "FATAL: overflow in vsnprintf (sgLogError): %s", strerror(errno));
va_end(ap);
@NOSYSLOG1@ if (globalSyslog == 1) {
#ifdef USE_SYSLOG
if (globalSyslog == 1) {
syslog(LOG_NOTICE, "%s\n", msg);
} else { @NOSYSLOG2@
sgLog(globalErrorLog, "%s", msg);
@NOSYSLOG1@ } @NOSYSLOG2@
} else {
sgLog(globalErrorLog, "%s", msg);
}
#else
sgLog(globalErrorLog, "%s", msg);
#endif
}

void sgLogWarn(char *format, ...)
Expand All @@ -109,11 +118,15 @@ void sgLogWarn(char *format, ...)
if (vsnprintf(msg, MAX_BUF, format, ap) > (MAX_BUF - 1))
sgLog(globalErrorLog, "FATAL: overflow in vsnprintf (sgLogError): %s", strerror(errno));
va_end(ap);
@NOSYSLOG1@ if (globalSyslog == 1) {
#ifdef USE_SYSLOG
if (globalSyslog == 1) {
syslog(LOG_WARNING, "%s\n", msg);
} else { @NOSYSLOG2@
sgLog(globalErrorLog, "%s", msg);
@NOSYSLOG1@ } @NOSYSLOG2@
} else {
sgLog(globalErrorLog, "%s", msg);
}
#else
sgLog(globalErrorLog, "%s", msg);
#endif
}

void sgLogError(char *format, ...)
Expand All @@ -124,11 +137,15 @@ void sgLogError(char *format, ...)
if (vsnprintf(msg, MAX_BUF, format, ap) > (MAX_BUF - 1))
sgLog(globalErrorLog, "FATAL: overflow in vsnprintf (sgLogError): %s", strerror(errno));
va_end(ap);
@NOSYSLOG1@ if (globalSyslog == 1) {
#ifdef USE_SYSLOG
if (globalSyslog == 1) {
syslog(LOG_ERR, "%s\n", msg);
} else { @NOSYSLOG2@
sgLog(globalErrorLog, "%s", msg);
@NOSYSLOG1@ } @NOSYSLOG2@
} else {
sgLog(globalErrorLog, "%s", msg);
}
#else
sgLog(globalErrorLog, "%s", msg);
#endif
}

void sgLogFatal(char *format, ...)
Expand All @@ -139,11 +156,15 @@ void sgLogFatal(char *format, ...)
if (vsnprintf(msg, MAX_BUF, format, ap) > (MAX_BUF - 1))
return;
va_end(ap);
@NOSYSLOG1@ if (globalSyslog == 1) {
#ifdef USE_SYSLOG
if (globalSyslog == 1) {
syslog(LOG_EMERG, "%s\n", msg);
} else { @NOSYSLOG2@
sgLog(globalErrorLog, "%s", msg);
@NOSYSLOG1@ } @NOSYSLOG2@
} else {
sgLog(globalErrorLog, "%s", msg);
}
#else
sgLog(globalErrorLog, "%s", msg);
#endif
sgEmergency();
}

Expand Down

0 comments on commit 554795d

Please sign in to comment.