tLogging functions now "work" properly in the client as well as in the server, and are used to report on plugin initialisation status; dopelog now takes one or more flags, LF_SERVER being the only one defined so far. - vaccinewars - be a doctor and try to vaccinate the world
(HTM) git clone git://src.adamsgaard.dk/vaccinewars
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 8c286f7d44154d5f675e311f7abb98d7aefa19fb
(DIR) parent 24453e1e2d2b1d870244ff70969992c5579d8169
(HTM) Author: Ben Webb <ben@salilab.org>
Date: Fri, 24 May 2002 11:32:40 +0000
Logging functions now "work" properly in the client as well as in the server,
and are used to report on plugin initialisation status; dopelog now takes
one or more flags, LF_SERVER being the only one defined so far.
Diffstat:
M src/dopewars.c | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)
---
(DIR) diff --git a/src/dopewars.c b/src/dopewars.c
t@@ -1456,13 +1456,15 @@ void RemoveAllEntries(DopeList *List, Player *Play)
* from 0 to 5 (0=vital, 2=normal, 5=maximum debugging output). This
* is essentially just a wrapper around the GLib g_log function.
*/
-void dopelog(int loglevel, const gchar *format, ...)
+void dopelog(const int loglevel, const LogFlags flags,
+ const gchar *format, ...)
{
va_list args;
- if (!Network)
- return; /* Don't print server log messages when
- * running standalone */
+ /* Don't print server log messages when running standalone */
+ if (flags & LF_SERVER && !Network)
+ return;
+
va_start(args, format);
g_logv(G_LOG_DOMAIN, 1 << (loglevel + G_LOG_LEVEL_USER_SHIFT), format,
args);
t@@ -2857,6 +2859,20 @@ gboolean GtkLoop(int *argc, char **argv[], gboolean ReturnOnFail)
}
#endif
+static void DefaultLogMessage(const gchar *log_domain,
+ GLogLevelFlags log_level,
+ const gchar *message, gpointer user_data)
+{
+ GString *text;
+
+ text = GetLogString(log_level, message);
+ if (text) {
+ g_string_append(text, "\n");
+ g_print(text->str);
+ g_string_free(text, TRUE);
+ }
+}
+
/*
* Standard program entry - Win32 uses WinMain() instead, in winmain.c
*/
t@@ -2868,9 +2884,10 @@ int main(int argc, char *argv[])
textdomain(PACKAGE);
#endif
WantUTF8Errors(FALSE);
- SoundInit();
+ g_log_set_handler(NULL, LogMask(), DefaultLogMessage, NULL);
GeneralStartup(argc, argv);
OpenLog();
+ SoundInit();
if (WantVersion || WantHelp) {
HandleHelpTexts();
} else if (WantAdmin) {