projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Even better svn-clean command.
[tinc]
/
src
/
logger.c
diff --git
a/src/logger.c
b/src/logger.c
index
871f2c1
..
dec88fd
100644
(file)
--- a/
src/logger.c
+++ b/
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.
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.
7 2003/07/29 10:50:15
guus Exp $
+ $Id: logger.c,v 1.1.2.
12 2003/10/06 16:13:07
guus Exp $
*/
#include "system.h"
*/
#include "system.h"
@@
-30,6
+30,9
@@
static logmode_t logmode = LOGMODE_STDERR;
static pid_t logpid;
extern char *logfilename;
static FILE *logfile = NULL;
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) {
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:
logmode = LOGMODE_NULL;
break;
case LOGMODE_SYSLOG:
+#ifdef HAVE_MINGW
+ loghandle = RegisterEventSource(NULL, logident);
+ if(!loghandle)
+ logmode = LOGMODE_NULL;
+ break;
+#else
#ifdef HAVE_SYSLOG_H
openlog(logident, LOG_CONS | LOG_PID, LOG_DAEMON);
break;
#ifdef HAVE_SYSLOG_H
openlog(logident, LOG_CONS | LOG_PID, LOG_DAEMON);
break;
+#endif
#endif
case LOGMODE_NULL:
break;
#endif
case LOGMODE_NULL:
break;
@@
-65,13
+75,23
@@
void logger(int priority, const char *format, ...) {
case LOGMODE_STDERR:
vfprintf(stderr, format, ap);
fprintf(stderr, "\n");
case LOGMODE_STDERR:
vfprintf(stderr, format, ap);
fprintf(stderr, "\n");
+ fflush(stderr);
break;
case LOGMODE_FILE:
break;
case LOGMODE_FILE:
- fprintf(logfile, "%ld %s[%
d]: ", time(NULL), logident,
logpid);
+ fprintf(logfile, "%ld %s[%
ld]: ", time(NULL), logident, (long)
logpid);
vfprintf(logfile, format, ap);
fprintf(logfile, "\n");
vfprintf(logfile, format, ap);
fprintf(logfile, "\n");
+ fflush(logfile);
break;
case LOGMODE_SYSLOG:
break;
case LOGMODE_SYSLOG:
+#ifdef HAVE_MINGW
+ {
+ char message[4096];
+ char *messages[] = {message};
+ vsnprintf(message, sizeof(message), format, ap);
+ ReportEvent(loghandle, priority, 0, 0, NULL, 1, 0, messages, NULL);
+ }
+#else
#ifdef HAVE_SYSLOG_H
#ifdef HAVE_VSYSLOG
vsyslog(priority, format, ap);
#ifdef HAVE_SYSLOG_H
#ifdef HAVE_VSYSLOG
vsyslog(priority, format, ap);
@@
-83,6
+103,7
@@
void logger(int priority, const char *format, ...) {
}
#endif
break;
}
#endif
break;
+#endif
#endif
case LOGMODE_NULL:
break;
#endif
case LOGMODE_NULL:
break;
@@
-97,9
+118,14
@@
void closelogger(void) {
fclose(logfile);
break;
case LOGMODE_SYSLOG:
fclose(logfile);
break;
case LOGMODE_SYSLOG:
+#ifdef HAVE_MINGW
+ DeregisterEventSource(loghandle);
+ break;
+#else
#ifdef HAVE_SYSLOG_H
closelog();
break;
#ifdef HAVE_SYSLOG_H
closelog();
break;
+#endif
#endif
case LOGMODE_NULL:
case LOGMODE_STDERR:
#endif
case LOGMODE_NULL:
case LOGMODE_STDERR: