2007-08-25 [paul] 2.10.0cvs173
[claws.git] / src / common / log.c
index 3d674b7dfce92d13acca47dc79e7753a7b2cb8c5..a3be1a7f07b9f016f409d8bb8700f94dc194d7f3 100644 (file)
@@ -4,7 +4,7 @@
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
@@ -13,8 +13,8 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * 
  */
 
 #ifdef HAVE_CONFIG_H
 
 #include "defs.h"
 
+#ifdef G_OS_WIN32
+#  include <w32lib.h>
+#endif
+
 #include <stdio.h>
 #include <glib.h>
 #include <glib/gi18n.h>
@@ -50,6 +54,11 @@ static LogInstanceData log_instances[LOG_INSTANCE_MAX] = {
        { DEBUG_FILTERING_APPEND_TEXT_HOOKLIST, NULL, NULL, NULL }
 };
 
+gboolean prefs_common_enable_log_standard(void);
+gboolean prefs_common_enable_log_warning(void);
+gboolean prefs_common_enable_log_error(void);
+gboolean prefs_common_enable_log_status(void);
+
 static gboolean invoke_hook_cb (gpointer data)
 {
        LogText *logtext = (LogText *)data;
@@ -131,15 +140,15 @@ void log_print(LogInstance instance, const gchar *format, ...)
        g_vsnprintf(buf + LOG_TIME_LEN, BUFFSIZE, format, args);
        va_end(args);
 
-       if (debug_get_mode()) fputs(buf, stdout);
+       if (debug_get_mode()) g_printf(buf);
 
        logtext->instance = instance;
        logtext->text = g_strdup(buf);
        logtext->type = LOG_NORMAL;
        
        g_timeout_add(0, invoke_hook_cb, logtext);
-       
-       if (log_fp[instance]) {
+
+       if (log_fp[instance] && prefs_common_enable_log_standard()) {
                fputs(buf, log_fp[instance]);
                fflush(log_fp[instance]);
        }
@@ -168,7 +177,7 @@ void log_message(LogInstance instance, const gchar *format, ...)
        
        g_timeout_add(0, invoke_hook_cb, logtext);
 
-       if (log_fp[instance]) {
+       if (log_fp[instance] && prefs_common_enable_log_standard()) {
                fwrite(buf, 1, LOG_TIME_LEN, log_fp[instance]);
                fputs("* message: ", log_fp[instance]);
                fputs(buf + LOG_TIME_LEN, log_fp[instance]);
@@ -199,7 +208,7 @@ void log_warning(LogInstance instance, const gchar *format, ...)
        
        g_timeout_add(0, invoke_hook_cb, logtext);
 
-       if (log_fp[instance]) {
+       if (log_fp[instance] && prefs_common_enable_log_warning()) {
                fwrite(buf, 1, LOG_TIME_LEN, log_fp[instance]);
                fputs("** warning: ", log_fp[instance]);
                fputs(buf + LOG_TIME_LEN, log_fp[instance]);
@@ -230,7 +239,7 @@ void log_error(LogInstance instance, const gchar *format, ...)
        
        g_timeout_add(0, invoke_hook_cb, logtext);
 
-       if (log_fp[instance]) {
+       if (log_fp[instance] && prefs_common_enable_log_error()) {
                fwrite(buf, 1, LOG_TIME_LEN, log_fp[instance]);
                fputs("*** error: ", log_fp[instance]);
                fputs(buf + LOG_TIME_LEN, log_fp[instance]);
@@ -261,7 +270,7 @@ void log_status_ok(LogInstance instance, const gchar *format, ...)
        
        g_timeout_add(0, invoke_hook_cb, logtext);
 
-       if (log_fp[instance]) {
+       if (log_fp[instance] && prefs_common_enable_log_status()) {
                fwrite(buf, 1, LOG_TIME_LEN, log_fp[instance]);
                fputs("* OK: ", log_fp[instance]);
                fputs(buf + LOG_TIME_LEN, log_fp[instance]);
@@ -292,7 +301,7 @@ void log_status_nok(LogInstance instance, const gchar *format, ...)
        
        g_timeout_add(0, invoke_hook_cb, logtext);
 
-       if (log_fp[instance]) {
+       if (log_fp[instance] && prefs_common_enable_log_status()) {
                fwrite(buf, 1, LOG_TIME_LEN, log_fp[instance]);
                fputs("* NOT OK: ", log_fp[instance]);
                fputs(buf + LOG_TIME_LEN, log_fp[instance]);
@@ -323,7 +332,7 @@ void log_status_skip(LogInstance instance, const gchar *format, ...)
        
        g_timeout_add(0, invoke_hook_cb, logtext);
 
-       if (log_fp[instance]) {
+       if (log_fp[instance] && prefs_common_enable_log_status()) {
                fwrite(buf, 1, LOG_TIME_LEN, log_fp[instance]);
                fputs("* SKIPPED: ", log_fp[instance]);
                fputs(buf + LOG_TIME_LEN, log_fp[instance]);