error.h
1/*
2 * Player - One Hell of a Robot Server
3 * Copyright (C) 2000
4 * Brian Gerkey, Kasper Stoy, Richard Vaughan, & Andrew Howard
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 ********************************************************************/
21
22/***************************************************************************
23 * Desc: Error handling macros
24 * Author: Andrew Howard
25 * Date: 13 May 2002
26 * CVS: $Id: error.h 8003 2009-07-13 10:34:37Z thjc $
27 **************************************************************************/
28
29#ifndef ERROR_HH
30#define ERROR_HH
31
32#include <stdio.h>
33#include <errno.h>
34
35#include <playerconfig.h>
36
37#if defined (WIN32)
38 #if defined (PLAYER_STATIC)
39 #define PLAYERERROR_EXPORT
40 #elif defined (playererror_EXPORTS)
41 #define PLAYERERROR_EXPORT __declspec (dllexport)
42 #else
43 #define PLAYERERROR_EXPORT __declspec (dllimport)
44 #endif
45#else
46 #define PLAYERERROR_EXPORT
47#endif
48
49#ifdef __cplusplus
50extern "C" {
51#endif
52
54PLAYERERROR_EXPORT void ErrorInit(int _msgLevel, FILE * logfile);
55
58PLAYERERROR_EXPORT void DefaultErrorPrint(int msgType, int level, const char *file, int line, const char *fmt, ...);
59
60PLAYERERROR_EXPORT extern void (*ErrorPrint)(int msgType, int level, const char *file, int line, const char *fmt, ...);
61PLAYERERROR_EXPORT extern int msgLevel;
62
63// File for logging messages
64PLAYERERROR_EXPORT extern FILE *msgFile;
65
66#ifdef __cplusplus
67}
68#endif
69
70
72#define PLAYER_ERR_ERR 0
73#define PLAYER_ERR_WARN 1
74#define PLAYER_ERR_MSG 2
75#define PLAYER_ERR_DBG 2
76
81#define PLAYER_ERROR(msg) ErrorPrint(PLAYER_ERR_ERR, 0, __FILE__, __LINE__, "error : " msg "\n")
82#define PLAYER_ERROR1(msg, a) ErrorPrint(PLAYER_ERR_ERR, 0, __FILE__, __LINE__, "error : " msg "\n", a)
83#define PLAYER_ERROR2(msg, a, b) ErrorPrint(PLAYER_ERR_ERR, 0, __FILE__, __LINE__, "error : " msg "\n", a, b)
84#define PLAYER_ERROR3(msg, a, b, c) ErrorPrint(PLAYER_ERR_ERR, 0, __FILE__, __LINE__, "error : " msg "\n", a, b, c)
85#define PLAYER_ERROR4(msg, a, b, c,d) ErrorPrint(PLAYER_ERR_ERR, 0, __FILE__, __LINE__, "error : " msg "\n", a, b, c, d)
86#define PLAYER_ERROR5(msg, a, b, c, d, e) ErrorPrint(PLAYER_ERR_ERR, 0, __FILE__, __LINE__, "error : " msg "\n", a, b, c, d, e)
87
89#define PLAYER_WARN(msg) ErrorPrint(PLAYER_ERR_WARN, 0, __FILE__, __LINE__, "warning : " msg "\n")
90#define PLAYER_WARN1(msg, a) ErrorPrint(PLAYER_ERR_WARN, 0, __FILE__, __LINE__, "warning : " msg "\n", a)
91#define PLAYER_WARN2(msg, a, b) ErrorPrint(PLAYER_ERR_WARN, 0, __FILE__, __LINE__, "warning : " msg "\n", a, b)
92#define PLAYER_WARN3(msg, a, b, c) ErrorPrint(PLAYER_ERR_WARN, 0, __FILE__, __LINE__, "warning : " msg "\n", a, b, c)
93#define PLAYER_WARN4(msg, a, b, c, d) ErrorPrint(PLAYER_ERR_WARN, 0, __FILE__, __LINE__, "warning : " msg "\n", a, b, c, d)
94#define PLAYER_WARN5(msg, a, b, c, d, e) ErrorPrint(PLAYER_ERR_WARN, 0, __FILE__, __LINE__, "warning : " msg "\n", a, b, c, d, e)
95#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)
96#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)
97
105#define PLAYER_MSG0(level, msg) ErrorPrint(PLAYER_ERR_MSG, level, __FILE__, __LINE__, "" msg "\n")
106#define PLAYER_MSG1(level, msg, a) ErrorPrint(PLAYER_ERR_MSG, level, __FILE__, __LINE__, "" msg "\n", a)
107#define PLAYER_MSG2(level, msg, a, b) ErrorPrint(PLAYER_ERR_MSG, level, __FILE__, __LINE__, "" msg "\n", a, b)
108#define PLAYER_MSG3(level, msg, a, b, c) ErrorPrint(PLAYER_ERR_MSG, level, __FILE__, __LINE__, "" msg "\n", a, b, c)
109#define PLAYER_MSG4(level, msg, a, b, c, d) ErrorPrint(PLAYER_ERR_MSG, level, __FILE__, __LINE__, "" msg "\n", a, b, c, d)
110#define PLAYER_MSG5(level, msg, a, b, c, d, e) ErrorPrint(PLAYER_ERR_MSG, level, __FILE__, __LINE__, "" msg "\n", a, b, c, d, e)
111#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)
112#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)
113
116#endif