[w32file] Remove dead code
[mono.git] / mono / utils / mono-log-posix.c
1 /**
2  * \file
3  * POSIX interface to the logger
4  *
5  * This module contains the POSIX syslog logger routines
6  *
7  * Author:
8  *    Neale Ferguson <neale@sinenomine.net>
9  *
10  */
11 #include <config.h>
12
13 #ifdef HAVE_UNISTD_H
14 #include <unistd.h>
15 #endif
16
17 #if defined(_POSIX_VERSION) 
18
19 #include <stdlib.h>
20 #include <stdio.h>
21 #include <ctype.h>
22 #include <string.h>
23 #include <glib.h>
24 #include <syslog.h>
25 #include <stdarg.h>
26 #include <errno.h>
27 #include <time.h>
28 #include <sys/time.h>
29 #include "mono-logger-internals.h"
30
31 static void *logUserData = NULL;
32
33 /**
34  * mapSyslogLevel:
35  *      
36  *      @level - GLogLevelFlags value
37  *      @returns The equivalent syslog priority value
38  */
39 static __inline__ int
40 mapSyslogLevel(GLogLevelFlags level) 
41 {
42         if (level & G_LOG_LEVEL_ERROR)
43                 return (LOG_ERR);
44         if (level & G_LOG_LEVEL_CRITICAL)
45                 return (LOG_CRIT);
46         if (level & G_LOG_LEVEL_WARNING)
47                 return (LOG_WARNING);
48         if (level & G_LOG_LEVEL_MESSAGE)
49                 return (LOG_NOTICE);
50         if (level & G_LOG_LEVEL_INFO)
51                 return (LOG_INFO);
52         if (level & G_LOG_LEVEL_DEBUG)
53                 return (LOG_DEBUG);
54         return (LOG_INFO);
55 }
56
57 /**
58  * mono_log_open_syslog:
59  * \param ident Identifier: ignored
60  * \param userData Not used
61  * Open the syslog interface specifying that we want our PID recorded 
62  * and that we're using the \c LOG_USER facility.
63  */
64 void
65 mono_log_open_syslog(const char *ident, void *userData)
66 {
67         openlog("mono", LOG_PID, LOG_USER);
68         logUserData = userData;
69 }
70
71 /**
72  * mono_log_write_syslog:
73  * \param domain Identifier string
74  * \param level Logging level flags
75  * \param format \c printf format string
76  * \param vargs Variable argument list
77  * Write data to the log file.
78  */
79 void
80 mono_log_write_syslog(const char *domain, GLogLevelFlags level, mono_bool hdr, const char *message)
81 {
82         syslog (mapSyslogLevel(level), "%s", message);
83
84         if (level & G_LOG_LEVEL_ERROR)
85                 abort();
86 }
87
88 /**
89  * mono_log_close_syslog:
90  * Close the log file
91  */
92 void
93 mono_log_close_syslog()
94 {
95         closelog();
96 }
97 #endif