diff options
author | Indent <please@skip.me> | 2015-02-19 02:47:20 -0300 |
---|---|---|
committer | dequis <dx@dxzone.com.ar> | 2015-02-20 19:50:54 -0300 |
commit | 5ebff60479fc7a9f7f50ac03b124c91d4e6ebe11 (patch) | |
tree | 9fc0d50cb1f4bc9768d9f00de94eafd876bb55b0 /log.c | |
parent | af359b4316f9d392c6b752495a1b2ed631576ed8 (diff) |
Reindent everything to K&R style with tabs
Used uncrustify, with the configuration file in ./doc/uncrustify.cfg
Commit author set to "Indent <please@skip.me>" so that it's easier to
skip while doing git blame.
Diffstat (limited to 'log.c')
-rw-r--r-- | log.c | 144 |
1 files changed, 85 insertions, 59 deletions
@@ -1,10 +1,10 @@ - /********************************************************************\ +/********************************************************************\ * BitlBee -- An IRC to other IM-networks gateway * * * * Copyright 2002-2005 Wilmer van der Gaast and others * \********************************************************************/ -/* Logging services for the bee */ +/* Logging services for the bee */ /* This program is free software; you can redistribute it and/or modify @@ -34,8 +34,9 @@ static void log_irc(int level, const char *logmessage); static void log_syslog(int level, const char *logmessage); static void log_console(int level, const char *logmessage); -void log_init(void) { - openlog("bitlbee", LOG_PID, LOG_DAEMON); +void log_init(void) +{ + openlog("bitlbee", LOG_PID, LOG_DAEMON); logoutput.informational = &log_null; logoutput.warning = &log_null; @@ -47,56 +48,60 @@ void log_init(void) { return; } -void log_link(int level, int output) { +void log_link(int level, int output) +{ /* I know it's ugly, but it works and I didn't feel like messing with pointer to function pointers */ - if(level == LOGLVL_INFO) { - if(output == LOGOUTPUT_NULL) - logoutput.informational = &log_null; - else if(output == LOGOUTPUT_IRC) - logoutput.informational = &log_irc; - else if(output == LOGOUTPUT_SYSLOG) - logoutput.informational = &log_syslog; - else if(output == LOGOUTPUT_CONSOLE) - logoutput.informational = &log_console; - } - else if(level == LOGLVL_WARNING) { - if(output == LOGOUTPUT_NULL) + if (level == LOGLVL_INFO) { + if (output == LOGOUTPUT_NULL) { + logoutput.informational = &log_null; + } else if (output == LOGOUTPUT_IRC) { + logoutput.informational = &log_irc; + } else if (output == LOGOUTPUT_SYSLOG) { + logoutput.informational = &log_syslog; + } else if (output == LOGOUTPUT_CONSOLE) { + logoutput.informational = &log_console; + } + } else if (level == LOGLVL_WARNING) { + if (output == LOGOUTPUT_NULL) { logoutput.warning = &log_null; - else if(output == LOGOUTPUT_IRC) + } else if (output == LOGOUTPUT_IRC) { logoutput.warning = &log_irc; - else if(output == LOGOUTPUT_SYSLOG) + } else if (output == LOGOUTPUT_SYSLOG) { logoutput.warning = &log_syslog; - else if(output == LOGOUTPUT_CONSOLE) + } else if (output == LOGOUTPUT_CONSOLE) { logoutput.warning = &log_console; - } - else if(level == LOGLVL_ERROR) { - if(output == LOGOUTPUT_NULL) + } + } else if (level == LOGLVL_ERROR) { + if (output == LOGOUTPUT_NULL) { logoutput.error = &log_null; - else if(output == LOGOUTPUT_IRC) + } else if (output == LOGOUTPUT_IRC) { logoutput.error = &log_irc; - else if(output == LOGOUTPUT_SYSLOG) + } else if (output == LOGOUTPUT_SYSLOG) { logoutput.error = &log_syslog; - else if(output == LOGOUTPUT_CONSOLE) + } else if (output == LOGOUTPUT_CONSOLE) { logoutput.error = &log_console; + } } #ifdef DEBUG - else if(level == LOGLVL_DEBUG) { - if(output == LOGOUTPUT_NULL) + else if (level == LOGLVL_DEBUG) { + if (output == LOGOUTPUT_NULL) { logoutput.debug = &log_null; - else if(output == LOGOUTPUT_IRC) + } else if (output == LOGOUTPUT_IRC) { logoutput.debug = &log_irc; - else if(output == LOGOUTPUT_SYSLOG) + } else if (output == LOGOUTPUT_SYSLOG) { logoutput.debug = &log_syslog; - else if(output == LOGOUTPUT_CONSOLE) + } else if (output == LOGOUTPUT_CONSOLE) { logoutput.debug = &log_console; + } } #endif - return; + return; } -void log_message(int level, const char *message, ... ) { +void log_message(int level, const char *message, ...) +{ va_list ap; char *msgstring; @@ -105,71 +110,92 @@ void log_message(int level, const char *message, ... ) { msgstring = g_strdup_vprintf(message, ap); va_end(ap); - if(level == LOGLVL_INFO) + if (level == LOGLVL_INFO) { (*(logoutput.informational))(level, msgstring); - if(level == LOGLVL_WARNING) + } + if (level == LOGLVL_WARNING) { (*(logoutput.warning))(level, msgstring); - if(level == LOGLVL_ERROR) + } + if (level == LOGLVL_ERROR) { (*(logoutput.error))(level, msgstring); + } #ifdef DEBUG - if(level == LOGLVL_DEBUG) + if (level == LOGLVL_DEBUG) { (*(logoutput.debug))(level, msgstring); + } #endif g_free(msgstring); - + return; } -void log_error(const char *functionname) { +void log_error(const char *functionname) +{ log_message(LOGLVL_ERROR, "%s: %s", functionname, strerror(errno)); - + return; } -static void log_null(int level, const char *message) { +static void log_null(int level, const char *message) +{ return; } -static void log_irc(int level, const char *message) { - if(level == LOGLVL_ERROR) +static void log_irc(int level, const char *message) +{ + if (level == LOGLVL_ERROR) { irc_write_all(1, "ERROR :Error: %s", message); - if(level == LOGLVL_WARNING) + } + if (level == LOGLVL_WARNING) { irc_write_all(0, "ERROR :Warning: %s", message); - if(level == LOGLVL_INFO) - irc_write_all(0, "ERROR :Informational: %s", message); + } + if (level == LOGLVL_INFO) { + irc_write_all(0, "ERROR :Informational: %s", message); + } #ifdef DEBUG - if(level == LOGLVL_DEBUG) - irc_write_all(0, "ERROR :Debug: %s", message); -#endif + if (level == LOGLVL_DEBUG) { + irc_write_all(0, "ERROR :Debug: %s", message); + } +#endif return; } -static void log_syslog(int level, const char *message) { - if(level == LOGLVL_ERROR) +static void log_syslog(int level, const char *message) +{ + if (level == LOGLVL_ERROR) { syslog(LOG_ERR, "%s", message); - if(level == LOGLVL_WARNING) + } + if (level == LOGLVL_WARNING) { syslog(LOG_WARNING, "%s", message); - if(level == LOGLVL_INFO) + } + if (level == LOGLVL_INFO) { syslog(LOG_INFO, "%s", message); + } #ifdef DEBUG - if(level == LOGLVL_DEBUG) + if (level == LOGLVL_DEBUG) { syslog(LOG_DEBUG, "%s", message); + } #endif return; } -static void log_console(int level, const char *message) { - if(level == LOGLVL_ERROR) +static void log_console(int level, const char *message) +{ + if (level == LOGLVL_ERROR) { fprintf(stderr, "Error: %s\n", message); - if(level == LOGLVL_WARNING) + } + if (level == LOGLVL_WARNING) { fprintf(stderr, "Warning: %s\n", message); - if(level == LOGLVL_INFO) + } + if (level == LOGLVL_INFO) { fprintf(stdout, "Informational: %s\n", message); + } #ifdef DEBUG - if(level == LOGLVL_DEBUG) + if (level == LOGLVL_DEBUG) { fprintf(stdout, "Debug: %s\n", message); + } #endif /* Always log stuff in syslogs too. */ log_syslog(level, message); |