1 /* Pioneers - Implementation of the excellent Settlers of Catan board game. 2 * Go buy a copy. 3 * 4 * Copyright (C) 1999 Dave Cole 5 * Copyright (C) 2003 Bas Wijnen <shevek@fmf.nl> 6 * Copyright (C) 2006 Roland Clobus <rclobus@bigfoot.com> 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 */ 22 23 #ifndef __log_h 24 #define __log_h 25 26 #include <glib.h> 27 #include <glib/gi18n.h> 28 29 /** Type of logging functions */ 30 typedef void (*LogFunc)(gint msg_type, const gchar * text); 31 32 /* Message Types */ 33 #define MSG_ERROR 1 34 #define MSG_INFO 2 35 #define MSG_CHAT 3 36 #define MSG_RESOURCE 4 37 #define MSG_BUILD 5 38 #define MSG_DICE 6 39 #define MSG_STEAL 7 40 #define MSG_TRADE 8 41 #define MSG_DEVCARD 9 42 #define MSG_LARGESTARMY 10 43 #define MSG_LONGESTROAD 11 44 #define MSG_BEEP 12 45 #define MSG_TIMESTAMP 13 46 #define MSG_PLAYER1 101 47 #define MSG_PLAYER2 102 48 #define MSG_PLAYER3 103 49 #define MSG_PLAYER4 104 50 #define MSG_PLAYER5 105 51 #define MSG_PLAYER6 106 52 #define MSG_PLAYER7 107 53 #define MSG_PLAYER8 108 54 #define MSG_SPECTATOR_CHAT 199 55 56 /** Set the logging function to 'func'. */ 57 void log_set_func(LogFunc func); 58 59 /** Set the logging function to the system default (stderr) */ 60 void log_set_func_default(void); 61 62 /** Write a message string to the console, adding a prefix depending on 63 * its type. 64 */ 65 void log_message_string_console(gint msg_type, const gchar * text); 66 67 /** Log a message after turning the params into a single string. */ 68 void log_message(gint msg_type, const gchar * fmt, ...); 69 70 /** Log a chat message. 71 * When the log function is not the default, only the chat is shown 72 * with msg_type, the other parts are shown with MSG_INFO. 73 * This means that player_name and joining_text are shown black, 74 * and the chat is in the colour of the player. 75 */ 76 void log_message_chat(const gchar * player_name, 77 const gchar * joining_text, gint msg_type, 78 const gchar * chat); 79 80 void set_enable_debug(gboolean enabled); 81 void debug(const gchar * fmt, ...); 82 83 #endif /* __log_h */ 84