Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2000:
[Freeciv-Dev] PATCH: log.h warning remove (3rd try)
Home

[Freeciv-Dev] PATCH: log.h warning remove (3rd try)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] PATCH: log.h warning remove (3rd try)
From: Dirk Stoecker <stoecker@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 20 Sep 2000 20:07:44 +0200 (MET DST)

Hi,

Ok, this is my last try to get rid of these ugly log.h warnings.

This patch splits log.h into log.h and logdefs.h, where logdefs.h
includes all the definitions and log.h the freelog stuff.

All files using freelog may call log.h, where all which do not use
freelog may call logdefs.h directly.

This affects server/console.c and server/civserver.c.
The logdebug_suppress_warning has been removed.

This is the cleanest way I can think of for solving that problem, so
I hope it is accepted this time. It needs no special definitions, no
obsolete code and nothing like that. It only needs not including log.h
if not needed (which is normal programming behaviour :-).

Ciao
 ____  _ _  ____  _ _    _ _  ____
|    |  |  |    |  | \  / |  |    | the cool Gremlin from Bischofswerda
|  __   |   ____|  |  \/  |  |    | WWW: http://home.pages.de/~stoecker/
|    |  |  |       |      |  |    | PGP key available on www page.
|____| _|_ |____| _|_    _|_ |____| I hope AMIGA never ends to make fun!
diff -Nur ../../freeciv-cvs/freeciv/common/log.h ./common/log.h
--- ../../freeciv-cvs/freeciv/common/log.h      Wed Sep 20 18:32:50 2000
+++ ./common/log.h      Wed Sep 20 18:31:33 2000
@@ -16,48 +16,10 @@
 #include <stdarg.h>
 
 #include "attribute.h"
+#include "logdefs.h"
 
-#define LOG_FATAL   0
-#define LOG_ERROR   1          /* non-fatal errors */
-#define LOG_NORMAL  2
-#define LOG_VERBOSE 3          /* not shown by default */
-#define LOG_DEBUG   4          /* suppressed unless DEBUG defined;
-                                  may be enabled on file/line basis */
-
-/* Some variables local to each file which includes log.h,
-   to record whether LOG_DEBUG messages apply for that file
-   and if so for which lines (min,max) :
-*/
-struct logdebug_afile_info {
-  int tthis;
-  int min;
-  int max;
-};
-#ifdef DEBUG
-static int logdebug_this_init;
-static struct logdebug_afile_info logdebug_thisfile;
-#endif
-
-extern int logd_init_counter;   /* increment this to force re-init */
-
-/* Return an updated struct logdebug_afile_info: */
-struct logdebug_afile_info logdebug_update(const char *file);
-
-
-/* A function type to enable custom output of log messages other than
- * via fputs(stderr).  Eg, to the server console while handling prompts,
- * rfcstyle, client notifications; Eg, to the client window output window?
- */
-typedef void (*log_callback_fn)(int, char*);
-
-int log_parse_level_str(char *level_str);
-void log_init(char *filename, int initial_level, log_callback_fn callback);
-void log_set_level(int level);
-
-void real_freelog(int level, char *message, ...)
-                  fc__attribute((format (printf, 2, 3)));
-void vreal_freelog(int level, char *message, va_list ap);
-
+/* Do not include log.h, but logdefs.h directly in case freelog function
+is not used! */
 
 /* A static (per-file) function to use/update the above per-file vars.
  * This should only be called for LOG_DEBUG messages.
@@ -75,13 +37,6 @@
                                      || (line >= logdebug_thisfile.min 
                                          && line <= logdebug_thisfile.max))); 
 }
-/* Including log.h without calling freelog() can generate a
-   warning that logdebug_check is never used; can use this to
-   suppress that warning:
-*/
-#define logdebug_suppress_warning logdebug_check(__FILE__, __LINE__)
-#else
-#define logdebug_suppress_warning
 #endif
 
 /* For GCC we use a variadic macro; for others we take
diff -Nur ../../freeciv-cvs/freeciv/common/logdefs.h ./common/logdefs.h
--- ../../freeciv-cvs/freeciv/common/logdefs.h  Thu Jan  1 01:00:00 1970
+++ ./common/logdefs.h  Wed Sep 20 18:32:51 2000
@@ -0,0 +1,61 @@
+/********************************************************************** 
+ Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
+   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, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+***********************************************************************/
+#ifndef FC__LOGDEFS_H
+#define FC__LOGDEFS_H
+
+#include <stdarg.h>
+
+#include "attribute.h"
+
+#define LOG_FATAL   0
+#define LOG_ERROR   1          /* non-fatal errors */
+#define LOG_NORMAL  2
+#define LOG_VERBOSE 3          /* not shown by default */
+#define LOG_DEBUG   4          /* suppressed unless DEBUG defined;
+                                  may be enabled on file/line basis */
+
+/* Some variables local to each file which includes log.h,
+   to record whether LOG_DEBUG messages apply for that file
+   and if so for which lines (min,max) :
+*/
+struct logdebug_afile_info {
+  int tthis;
+  int min;
+  int max;
+};
+#ifdef DEBUG
+static int logdebug_this_init;
+static struct logdebug_afile_info logdebug_thisfile;
+#endif
+
+extern int logd_init_counter;   /* increment this to force re-init */
+
+/* Return an updated struct logdebug_afile_info: */
+struct logdebug_afile_info logdebug_update(const char *file);
+
+
+/* A function type to enable custom output of log messages other than
+ * via fputs(stderr).  Eg, to the server console while handling prompts,
+ * rfcstyle, client notifications; Eg, to the client window output window?
+ */
+typedef void (*log_callback_fn)(int, char*);
+
+int log_parse_level_str(char *level_str);
+void log_init(char *filename, int initial_level, log_callback_fn callback);
+void log_set_level(int level);
+
+void real_freelog(int level, char *message, ...)
+                  fc__attribute((format (printf, 2, 3)));
+void vreal_freelog(int level, char *message, va_list ap);
+
+#endif  /* FC__LOGDEFS_H */
diff -Nur ../../freeciv-cvs/freeciv/server/civserver.c ./server/civserver.c
--- ../../freeciv-cvs/freeciv/server/civserver.c        Wed Sep 20 18:33:09 2000
+++ ./server/civserver.c        Wed Sep 20 18:34:39 2000
@@ -25,7 +25,7 @@
 #endif
 
 #include "fcintl.h"
-#include "log.h"
+#include "logdefs.h"
 #include "shared.h"
 #include "support.h"
 #include "version.h"
@@ -142,9 +142,6 @@
 
   /* have arguments, call the main server loop... */
   srv_main();
-
-  /* suppress warnings */
-  logdebug_suppress_warning;
 
   /* done */
   return 0;
diff -Nur ../../freeciv-cvs/freeciv/server/console.c ./server/console.c
--- ../../freeciv-cvs/freeciv/server/console.c  Wed Sep 20 18:33:07 2000
+++ ./server/console.c  Wed Sep 20 18:34:18 2000
@@ -23,7 +23,7 @@
 #endif
 
 #include "fcintl.h"
-#include "log.h"
+#include "logdefs.h"
 #include "support.h"
 
 #include "srv_main.h"
@@ -78,7 +78,6 @@
 void con_log_init(char *log_filename, int log_level)
 {
   log_init(log_filename, log_level, (log_filename ? NULL : con_handle_log));
-  logdebug_suppress_warning;
 }
 
 /************************************************************************

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] PATCH: log.h warning remove (3rd try), Dirk Stoecker <=