error.h
00001 /*
00002  *  Player - One Hell of a Robot Server
00003  *  Copyright (C) 2000
00004  *     Brian Gerkey, Kasper Stoy, Richard Vaughan, & Andrew Howard
00005  *
00006  *  This library is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU Lesser General Public
00008  *  License as published by the Free Software Foundation; either
00009  *  version 2.1 of the License, or (at your option) any later version.
00010  *
00011  *  This library is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  *  Lesser General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU Lesser General Public
00017  *  License along with this library; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  ********************************************************************/
00021 
00022 /***************************************************************************
00023  * Desc: Error handling macros
00024  * Author: Andrew Howard
00025  * Date: 13 May 2002
00026  * CVS: $Id: error.h 8003 2009-07-13 10:34:37Z thjc $
00027  **************************************************************************/
00028 
00029 #ifndef ERROR_HH
00030 #define ERROR_HH
00031 
00032 #include <stdio.h>
00033 #include <errno.h>
00034 
00035 #include <playerconfig.h>
00036 
00037 #if defined (WIN32)
00038   #if defined (PLAYER_STATIC)
00039     #define PLAYERERROR_EXPORT
00040   #elif defined (playererror_EXPORTS)
00041     #define PLAYERERROR_EXPORT    __declspec (dllexport)
00042   #else
00043     #define PLAYERERROR_EXPORT    __declspec (dllimport)
00044   #endif
00045 #else
00046   #define PLAYERERROR_EXPORT
00047 #endif
00048 
00049 #ifdef __cplusplus
00050 extern "C" {
00051 #endif
00052 
00054 PLAYERERROR_EXPORT void ErrorInit(int _msgLevel, FILE * logfile);
00055 
00058 PLAYERERROR_EXPORT void DefaultErrorPrint(int msgType, int level, const char *file, int line, const char *fmt, ...);
00059 
00060 PLAYERERROR_EXPORT extern void (*ErrorPrint)(int msgType, int level, const char *file, int line, const char *fmt, ...);
00061 PLAYERERROR_EXPORT extern int msgLevel;
00062 
00063 // File for logging messages
00064 PLAYERERROR_EXPORT extern FILE *msgFile;
00065 
00066 #ifdef __cplusplus
00067 }
00068 #endif
00069 
00070 
00072 #define PLAYER_ERR_ERR 0
00073 #define PLAYER_ERR_WARN 1
00074 #define PLAYER_ERR_MSG 2
00075 #define PLAYER_ERR_DBG 2
00076 
00080 
00081 #define PLAYER_ERROR(msg)         ErrorPrint(PLAYER_ERR_ERR, 0, __FILE__, __LINE__, "error   : " msg "\n")
00082 #define PLAYER_ERROR1(msg, a)     ErrorPrint(PLAYER_ERR_ERR, 0, __FILE__, __LINE__, "error   : " msg "\n", a)
00083 #define PLAYER_ERROR2(msg, a, b)  ErrorPrint(PLAYER_ERR_ERR, 0, __FILE__, __LINE__, "error   : " msg "\n", a, b)
00084 #define PLAYER_ERROR3(msg, a, b, c)  ErrorPrint(PLAYER_ERR_ERR, 0, __FILE__, __LINE__,  "error   : " msg "\n", a, b, c)
00085 #define PLAYER_ERROR4(msg, a, b, c,d)  ErrorPrint(PLAYER_ERR_ERR, 0, __FILE__, __LINE__,  "error   : " msg "\n", a, b, c, d)
00086 #define PLAYER_ERROR5(msg, a, b, c, d, e)  ErrorPrint(PLAYER_ERR_ERR, 0, __FILE__, __LINE__,  "error   : " msg "\n", a, b, c, d, e)
00087 
00089 #define PLAYER_WARN(msg)        ErrorPrint(PLAYER_ERR_WARN, 0, __FILE__, __LINE__, "warning : " msg "\n")
00090 #define PLAYER_WARN1(msg, a)    ErrorPrint(PLAYER_ERR_WARN, 0, __FILE__, __LINE__, "warning : " msg "\n", a)
00091 #define PLAYER_WARN2(msg, a, b) ErrorPrint(PLAYER_ERR_WARN, 0, __FILE__, __LINE__, "warning : " msg "\n", a, b)
00092 #define PLAYER_WARN3(msg, a, b, c) ErrorPrint(PLAYER_ERR_WARN, 0, __FILE__, __LINE__, "warning : " msg "\n", a, b, c)
00093 #define PLAYER_WARN4(msg, a, b, c, d) ErrorPrint(PLAYER_ERR_WARN, 0, __FILE__, __LINE__, "warning : " msg "\n", a, b, c, d)
00094 #define PLAYER_WARN5(msg, a, b, c, d, e) ErrorPrint(PLAYER_ERR_WARN, 0, __FILE__, __LINE__, "warning : " msg "\n", a, b, c, d, e)
00095 #define PLAYER_WARN6(msg, a, b, c, d, e, f) ErrorPrint(PLAYER_ERR_WARN, 0, __FILE__, __LINE__, "warning : " msg "\n", a, b, c, d, e, f)
00096 #define PLAYER_WARN7(msg, a, b, c, d, e, f, g) ErrorPrint(PLAYER_ERR_WARN, 0, __FILE__, __LINE__, "warning : " msg "\n", a, b, c, d, e, f, g)
00097 
00105 #define PLAYER_MSG0(level, msg) ErrorPrint(PLAYER_ERR_MSG, level, __FILE__, __LINE__, "" msg "\n") 
00106 #define PLAYER_MSG1(level, msg, a) ErrorPrint(PLAYER_ERR_MSG, level, __FILE__, __LINE__, "" msg "\n", a) 
00107 #define PLAYER_MSG2(level, msg, a, b)  ErrorPrint(PLAYER_ERR_MSG, level, __FILE__, __LINE__, "" msg "\n", a, b)
00108 #define PLAYER_MSG3(level, msg, a, b, c) ErrorPrint(PLAYER_ERR_MSG, level, __FILE__, __LINE__, "" msg "\n", a, b, c)
00109 #define PLAYER_MSG4(level, msg, a, b, c, d) ErrorPrint(PLAYER_ERR_MSG, level, __FILE__, __LINE__, "" msg "\n", a, b, c, d)
00110 #define PLAYER_MSG5(level, msg, a, b, c, d, e) ErrorPrint(PLAYER_ERR_MSG, level, __FILE__, __LINE__, "" msg "\n", a, b, c, d, e)
00111 #define PLAYER_MSG6(level, msg, a, b, c, d, e, f) ErrorPrint(PLAYER_ERR_MSG, level, __FILE__, __LINE__, "" msg "\n", a, b, c, d, e, f)
00112 #define PLAYER_MSG7(level, msg, a, b, c, d, e, f, g) ErrorPrint(PLAYER_ERR_MSG, level, __FILE__, __LINE__, "" msg "\n", a, b, c, d, e, f, g)
00113 
00116 #endif

Last updated 25 May 2011 21:17:00