Use the event log under Windows.
This commit is contained in:
parent
5e7c52610f
commit
3112e6a863
2 changed files with 35 additions and 1 deletions
25
src/logger.c
25
src/logger.c
|
@ -17,7 +17,7 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
$Id: logger.c,v 1.1.2.9 2003/08/02 20:50:38 guus Exp $
|
||||
$Id: logger.c,v 1.1.2.10 2003/08/17 09:04:00 guus Exp $
|
||||
*/
|
||||
|
||||
#include "system.h"
|
||||
|
@ -30,6 +30,9 @@ static logmode_t logmode = LOGMODE_STDERR;
|
|||
static pid_t logpid;
|
||||
extern char *logfilename;
|
||||
static FILE *logfile = NULL;
|
||||
#ifdef HAVE_MINGW
|
||||
static HANDLE loghandle = NULL;
|
||||
#endif
|
||||
static const char *logident = NULL;
|
||||
|
||||
void openlogger(const char *ident, logmode_t mode) {
|
||||
|
@ -47,9 +50,16 @@ void openlogger(const char *ident, logmode_t mode) {
|
|||
logmode = LOGMODE_NULL;
|
||||
break;
|
||||
case LOGMODE_SYSLOG:
|
||||
#ifdef HAVE_MINGW
|
||||
loghandle = OpenEventLog(NULL, identname);
|
||||
if(!loghandle)
|
||||
logmode = LOGMODE_NULL;
|
||||
break;
|
||||
#else
|
||||
#ifdef HAVE_SYSLOG_H
|
||||
openlog(logident, LOG_CONS | LOG_PID, LOG_DAEMON);
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
case LOGMODE_NULL:
|
||||
break;
|
||||
|
@ -74,6 +84,13 @@ void logger(int priority, const char *format, ...) {
|
|||
fflush(logfile);
|
||||
break;
|
||||
case LOGMODE_SYSLOG:
|
||||
#ifdef HAVE_MINGW
|
||||
{
|
||||
char message[4096];
|
||||
vsnprintf(message, sizeof(message), format, ap);
|
||||
ReportEvent(loghandle, priority, 0, 0, NULL, 1, 0, &message, NULL);
|
||||
}
|
||||
#else
|
||||
#ifdef HAVE_SYSLOG_H
|
||||
#ifdef HAVE_VSYSLOG
|
||||
vsyslog(priority, format, ap);
|
||||
|
@ -85,6 +102,7 @@ void logger(int priority, const char *format, ...) {
|
|||
}
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
case LOGMODE_NULL:
|
||||
break;
|
||||
|
@ -99,9 +117,14 @@ void closelogger(void) {
|
|||
fclose(logfile);
|
||||
break;
|
||||
case LOGMODE_SYSLOG:
|
||||
#ifdef HAVE_MINGW
|
||||
CloseEventLog(loghandle);
|
||||
break;
|
||||
#else
|
||||
#ifdef HAVE_SYSLOG_H
|
||||
closelog();
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
case LOGMODE_NULL:
|
||||
case LOGMODE_STDERR:
|
||||
|
|
11
src/logger.h
11
src/logger.h
|
@ -21,6 +21,16 @@ typedef enum logmode_t {
|
|||
LOGMODE_SYSLOG
|
||||
} logmode_t;
|
||||
|
||||
#ifdef HAVE_MINGW
|
||||
#define LOG_EMERG EVENTLOG_ERROR_TYPE
|
||||
#define LOG_ALERT EVENTLOG_ERROR_TYPE
|
||||
#define LOG_CRIT EVENTLOG_ERROR_TYPE
|
||||
#define LOG_ERR EVENTLOG_ERROR_TYPE
|
||||
#define LOG_WARNING EVENTLOG_WARNING_TYPE
|
||||
#define LOG_NOTICE EVENTLOG_INFORMATION_TYPE
|
||||
#define LOG_INFO EVENTLOG_INFORMATION_TYPE
|
||||
#define LOG_DEBUG EVENTLOG_INFORMATION_TYPE
|
||||
#else
|
||||
#ifndef HAVE_SYSLOG_H
|
||||
enum {
|
||||
LOG_EMERG,
|
||||
|
@ -33,6 +43,7 @@ enum {
|
|||
LOG_DEBUG,
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern debug_t debug_level;
|
||||
extern void openlogger(const char *, logmode_t);
|
||||
|
|
Loading…
Reference in a new issue