1 /*****************************************************************************
2  * Author:   Valient Gough <vgough@pobox.com>
3  *
4  *****************************************************************************
5  * Copyright (c) 2002-2004, Valient Gough
6  *
7  * This library is free software; you can distribute it and/or modify it under
8  * the terms of the GNU Lesser General Public License (LGPL), as published by
9  * the Free Software Foundation; either version 2.1 of the License, or (at your
10  * option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE.  See the LGPL in the file COPYING for more
15  * details.
16  *
17  */
18 
19 #define _rMessageDef(ID, COMPONENT) \
20   static bool ID ## _enabled = true; \
21   static rlog::PublishLoc ID RLOG_SECTION = {& ID ## _enabled, \
22       &rlog::RLog_Register, 0, STR(COMPONENT), __FILE__, \
23       __FUNCTION__, __LINE__, 0};
24 
25 
26 #if HAVE_PRINTF_FP || !HAVE_PRINTF_ATTR
27 #  define _rMessageCall(ID, CHANNEL, ARGS...) \
28   if(unlikely(ID ## _enabled)) (*ID.publish)( &ID, CHANNEL, ##ARGS );
29 #else
30 # define _rMessageCall(ID, CHANNEL, ARGS...) \
31   if(unlikely(ID ## _enabled))  \
32   { \
33     (*ID.publish)( &ID, CHANNEL, ##ARGS ); \
34     rlog::__checkArgs( 0, ##ARGS ); \
35   }
36 #endif
37 
38 
39 
40 #define _rMessage(ID, CHANNEL, ARGS... ) \
41   do { _rMessageDef(ID, RLOG_COMPONENT) \
42        _rMessageCall(ID, CHANNEL, ##ARGS ) } while(0)
43 
44 
45 #define rDebug(ARGS...) \
46   _rMessage( LOGID, rlog::_RLDebugChannel, ##ARGS )
47 
48 #define rInfo(ARGS...) \
49   _rMessage( LOGID, rlog::_RLInfoChannel, ##ARGS )
50 
51 #define rWarning(ARGS...) \
52   _rMessage( LOGID, rlog::_RLWarningChannel, ##ARGS )
53 
54 #define rError(ARGS...) \
55   _rMessage( LOGID, rlog::_RLErrorChannel, ##ARGS )
56 
57 #define rLog(channel, ARGS...) \
58   _rMessage( LOGID, channel, ##ARGS )
59 
60 
61