2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2002 Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 static FILE *log_fp = NULL;
32 void set_log_file(const gchar *filename)
35 log_fp = fopen(filename, "wb");
37 FILE_OP_ERROR(filename, "fopen");
40 void close_log_file(void)
48 static guint log_verbosity_count = 0;
50 void log_verbosity_set(gboolean verbose)
53 log_verbosity_count++;
54 else if (log_verbosity_count > 0)
55 log_verbosity_count--;
60 void log_print(const gchar *format, ...)
63 gchar buf[BUFFSIZE + TIME_LEN];
67 strftime(buf, TIME_LEN + 1, "[%H:%M:%S] ", localtime(&t));
69 va_start(args, format);
70 g_vsnprintf(buf + TIME_LEN, BUFFSIZE, format, args);
73 if (debug_get_mode()) fputs(buf, stdout);
75 callback for gui logging
77 log_window_append(buf, LOG_NORMAL); */
83 callback for gui logging
85 if (log_verbosity_count)
86 statusbar_puts_all(buf + TIME_LEN); */
89 void log_message(const gchar *format, ...)
92 gchar buf[BUFFSIZE + TIME_LEN];
96 strftime(buf, TIME_LEN + 1, "[%H:%M:%S] ", localtime(&t));
98 va_start(args, format);
99 g_vsnprintf(buf + TIME_LEN, BUFFSIZE, format, args);
102 if (debug_get_mode()) g_message("%s", buf + TIME_LEN);
104 callback for gui logging
106 log_window_append(buf + TIME_LEN, LOG_MSG); */
108 fwrite(buf, TIME_LEN, 1, log_fp);
109 fputs("* message: ", log_fp);
110 fputs(buf + TIME_LEN, log_fp);
114 callback for gui logging
116 statusbar_puts_all(buf + TIME_LEN); */
119 void log_warning(const gchar *format, ...)
122 gchar buf[BUFFSIZE + TIME_LEN];
126 strftime(buf, TIME_LEN + 1, "[%H:%M:%S] ", localtime(&t));
128 va_start(args, format);
129 g_vsnprintf(buf + TIME_LEN, BUFFSIZE, format, args);
132 g_warning("%s", buf);
134 callback for gui logging
136 log_window_append(buf + TIME_LEN, LOG_WARN); */
138 fwrite(buf, TIME_LEN, 1, log_fp);
139 fputs("** warning: ", log_fp);
140 fputs(buf + TIME_LEN, log_fp);
145 void log_error(const gchar *format, ...)
148 gchar buf[BUFFSIZE + TIME_LEN];
152 strftime(buf, TIME_LEN + 1, "[%H:%M:%S] ", localtime(&t));
154 va_start(args, format);
155 g_vsnprintf(buf + TIME_LEN, BUFFSIZE, format, args);
158 g_warning("%s", buf);
160 callback for gui logging
162 log_window_append(buf + TIME_LEN, LOG_ERROR); */
164 fwrite(buf, TIME_LEN, 1, log_fp);
165 fputs("*** error: ", log_fp);
166 fputs(buf + TIME_LEN, log_fp);