comparison src/log.c @ 15:f671821d8222

code beautifying; 0 -> \0 if appropriate
author meillo@marmaro.de
date Thu, 06 Nov 2008 09:18:38 +0100
parents 26e34ae9a3e3
children e507c854a63e
comparison
equal deleted inserted replaced
14:a8f3424347dc 15:f671821d8222
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software 15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */ 17 */
18 18
19 #include <sysexits.h>
20
19 #include "masqmail.h" 21 #include "masqmail.h"
20
21 #include "sysexits.h"
22 22
23 static char *_sysexit_strings[] = { 23 static char *_sysexit_strings[] = {
24 "command line usage error", 24 "command line usage error",
25 "data format error", 25 "data format error",
26 "cannot open input", 26 "cannot open input",
107 } 107 }
108 108
109 void 109 void
110 vlogwrite(int pri, const char *fmt, va_list args) 110 vlogwrite(int pri, const char *fmt, va_list args)
111 { 111 {
112 if ((conf.do_verbose && (pri & LOG_VERBOSE)) || (pri == LOG_ALERT) 112 if ((conf.do_verbose && (pri & LOG_VERBOSE)) || (pri == LOG_ALERT) || (pri == LOG_WARNING)) {
113 || (pri == LOG_WARNING)) {
114 va_list args_copy; 113 va_list args_copy;
115 va_copy(args_copy, args); 114 va_copy(args_copy, args);
116 vfprintf(stdout, fmt, args_copy); 115 vfprintf(stdout, fmt, args_copy);
117 va_end(args_copy); 116 va_end(args_copy);
118 fflush(stdout); /* is this necessary? */ 117 fflush(stdout); /* is this necessary? */
119 } 118 }
120 119
121 pri &= ~LOG_VERBOSE; 120 pri &= ~LOG_VERBOSE;
122 if (pri) { 121 if (pri) {
123
124 if (conf.use_syslog) 122 if (conf.use_syslog)
125 vsyslog(pri, fmt, args); 123 vsyslog(pri, fmt, args);
126 else { 124 else {
127 if (pri <= conf.log_max_pri) { 125 if (pri <= conf.log_max_pri) {
128 FILE *file = logfile ? logfile : stderr; 126 FILE *file = logfile ? logfile : stderr;
157 gchar buf[24]; 155 gchar buf[24];
158 strftime(buf, 24, "%Y-%m-%d %H:%M:%S", t); 156 strftime(buf, 24, "%Y-%m-%d %H:%M:%S", t);
159 157
160 if (debugfile) { 158 if (debugfile) {
161 fprintf(debugfile, "%s [%d] ", buf, getpid()); 159 fprintf(debugfile, "%s [%d] ", buf, getpid());
162
163 vfprintf(debugfile, fmt, args); 160 vfprintf(debugfile, fmt, args);
164 fflush(debugfile); 161 fflush(debugfile);
165 } else { 162 } else {
166 fprintf(stderr, "no debug file, msg was:\n"); 163 fprintf(stderr, "no debug file, msg was:\n");
167 vfprintf(stderr, fmt, args); 164 vfprintf(stderr, fmt, args);