Changeset ac9f0e9
- Timestamp:
- 2006-01-18T07:53:50Z (19 years ago)
- Branches:
- master
- Children:
- c1826c6
- Parents:
- 277674c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
log.c
r277674c rac9f0e9 38 38 openlog("bitlbee", LOG_PID, LOG_DAEMON); 39 39 40 logoutput.informational =&log_null;41 logoutput.warning =&log_null;42 logoutput.error =&log_null;40 logoutput.informational = &log_null; 41 logoutput.warning = &log_null; 42 logoutput.error = &log_null; 43 43 #ifdef DEBUG 44 logoutput.debug =&log_null;44 logoutput.debug = &log_null; 45 45 #endif 46 46 … … 51 51 /* I know it's ugly, but it works and I didn't feel like messing with pointer to function pointers */ 52 52 53 if(level ==LOGLVL_INFO) {54 if(output ==LOGOUTPUT_NULL)55 logoutput.informational =&log_null;56 else if(output ==LOGOUTPUT_IRC)57 logoutput.informational =&log_irc;58 else if(output ==LOGOUTPUT_SYSLOG)59 logoutput.informational =&log_syslog;60 else if(output ==LOGOUTPUT_CONSOLE)61 logoutput.informational =&log_console;53 if(level == LOGLVL_INFO) { 54 if(output == LOGOUTPUT_NULL) 55 logoutput.informational = &log_null; 56 else if(output == LOGOUTPUT_IRC) 57 logoutput.informational = &log_irc; 58 else if(output == LOGOUTPUT_SYSLOG) 59 logoutput.informational = &log_syslog; 60 else if(output == LOGOUTPUT_CONSOLE) 61 logoutput.informational = &log_console; 62 62 } 63 else if(level ==LOGLVL_WARNING) {64 if(output ==LOGOUTPUT_NULL)65 logoutput.warning =&log_null;66 else if(output ==LOGOUTPUT_IRC)67 logoutput.warning =&log_irc;68 else if(output ==LOGOUTPUT_SYSLOG)69 logoutput.warning =&log_syslog;70 else if(output ==LOGOUTPUT_CONSOLE)71 logoutput.warning =&log_console;63 else if(level == LOGLVL_WARNING) { 64 if(output == LOGOUTPUT_NULL) 65 logoutput.warning = &log_null; 66 else if(output == LOGOUTPUT_IRC) 67 logoutput.warning = &log_irc; 68 else if(output == LOGOUTPUT_SYSLOG) 69 logoutput.warning = &log_syslog; 70 else if(output == LOGOUTPUT_CONSOLE) 71 logoutput.warning = &log_console; 72 72 } 73 else if(level ==LOGLVL_ERROR) {74 if(output ==LOGOUTPUT_NULL)75 logoutput.error =&log_null;76 else if(output ==LOGOUTPUT_IRC)77 logoutput.error =&log_irc;78 else if(output ==LOGOUTPUT_SYSLOG)79 logoutput.error =&log_syslog;80 else if(output ==LOGOUTPUT_CONSOLE)81 logoutput.error =&log_console;73 else if(level == LOGLVL_ERROR) { 74 if(output == LOGOUTPUT_NULL) 75 logoutput.error = &log_null; 76 else if(output == LOGOUTPUT_IRC) 77 logoutput.error = &log_irc; 78 else if(output == LOGOUTPUT_SYSLOG) 79 logoutput.error = &log_syslog; 80 else if(output == LOGOUTPUT_CONSOLE) 81 logoutput.error = &log_console; 82 82 } 83 83 #ifdef DEBUG 84 else if(level ==LOGLVL_DEBUG) {85 if(output ==LOGOUTPUT_NULL)86 logoutput.debug =&log_null;87 else if(output ==LOGOUTPUT_IRC)88 logoutput.debug =&log_irc;89 else if(output ==LOGOUTPUT_SYSLOG)90 logoutput.debug =&log_syslog;91 else if(output ==LOGOUTPUT_CONSOLE)92 logoutput.debug =&log_console;84 else if(level == LOGLVL_DEBUG) { 85 if(output == LOGOUTPUT_NULL) 86 logoutput.debug = &log_null; 87 else if(output == LOGOUTPUT_IRC) 88 logoutput.debug = &log_irc; 89 else if(output == LOGOUTPUT_SYSLOG) 90 logoutput.debug = &log_syslog; 91 else if(output == LOGOUTPUT_CONSOLE) 92 logoutput.debug = &log_console; 93 93 } 94 94 #endif … … 106 106 va_end(ap); 107 107 108 if(level ==LOGLVL_INFO)108 if(level == LOGLVL_INFO) 109 109 (*(logoutput.informational))(level, msgstring); 110 if(level ==LOGLVL_WARNING)110 if(level == LOGLVL_WARNING) 111 111 (*(logoutput.warning))(level, msgstring); 112 if(level ==LOGLVL_ERROR)112 if(level == LOGLVL_ERROR) 113 113 (*(logoutput.error))(level, msgstring); 114 114 #ifdef DEBUG 115 if(level ==LOGLVL_DEBUG)115 if(level == LOGLVL_DEBUG) 116 116 (*(logoutput.debug))(level, msgstring); 117 117 #endif … … 133 133 134 134 static void log_irc(int level, char *message) { 135 if(level ==LOGLVL_ERROR)135 if(level == LOGLVL_ERROR) 136 136 irc_write_all(1, "ERROR :Error: %s", message); 137 if(level ==LOGLVL_WARNING)137 if(level == LOGLVL_WARNING) 138 138 irc_write_all(0, "ERROR :Warning: %s", message); 139 if(level ==LOGLVL_INFO)139 if(level == LOGLVL_INFO) 140 140 irc_write_all(0, "ERROR :Informational: %s", message); 141 141 #ifdef DEBUG 142 if(level ==LOGLVL_DEBUG)142 if(level == LOGLVL_DEBUG) 143 143 irc_write_all(0, "ERROR :Debug: %s", message); 144 144 #endif … … 148 148 149 149 static void log_syslog(int level, char *message) { 150 if(level ==LOGLVL_ERROR)150 if(level == LOGLVL_ERROR) 151 151 syslog(LOG_ERR, "%s", message); 152 if(level ==LOGLVL_WARNING)152 if(level == LOGLVL_WARNING) 153 153 syslog(LOG_WARNING, "%s", message); 154 if(level ==LOGLVL_INFO)154 if(level == LOGLVL_INFO) 155 155 syslog(LOG_INFO, "%s", message); 156 156 #ifdef DEBUG 157 if(level ==LOGLVL_DEBUG)157 if(level == LOGLVL_DEBUG) 158 158 syslog(LOG_DEBUG, "%s", message); 159 159 #endif … … 162 162 163 163 static void log_console(int level, char *message) { 164 if(level ==LOGLVL_ERROR)164 if(level == LOGLVL_ERROR) 165 165 fprintf(stderr, "Error: %s\n", message); 166 if(level ==LOGLVL_WARNING)166 if(level == LOGLVL_WARNING) 167 167 fprintf(stderr, "Warning: %s\n", message); 168 if(level ==LOGLVL_INFO)168 if(level == LOGLVL_INFO) 169 169 fprintf(stdout, "Informational: %s\n", message); 170 170 #ifdef DEBUG 171 if(level ==LOGLVL_DEBUG)171 if(level == LOGLVL_DEBUG) 172 172 fprintf(stdout, "Debug: %s\n", message); 173 173 #endif
Note: See TracChangeset
for help on using the changeset viewer.