/usr/include/rlog/rlog.h is in librlog-dev 1.4-2.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | /*****************************************************************************
* Author: Valient Gough <vgough@pobox.com>
*
*****************************************************************************
* Copyright (c) 2002-2004, Valient Gough
*
* This library is free software; you can distribute it and/or modify it under
* the terms of the GNU Lesser General Public License (LGPL), as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the LGPL in the file COPYING for more
* details.
*
*/
#ifndef _rlog_incl_
#define _rlog_incl_
#define CONCAT2(A,B) A##B
#define CONCAT(A,B) CONCAT2(A,B)
#define STR(X) #X
#include <rlog/common.h>
/*! @file rlog.h
@brief Defines macros for debug, warning, and error messages.
*/
// may be useful for checking from configuration files
#define CURRENT_RLOG_VERSION 20040503
extern "C" int RLogVersion();
namespace rlog
{
class RLogChannel;
class RLogPublisher;
class RLogNode;
/*! @enum LogLevel
Logging level definitions.
*/
enum LogLevel
{
Log_Undef =0, //!< undefined level
Log_Critical, //!< critical conditions
Log_Error, //!< error conditions
Log_Warning, //!< warning conditions
Log_Notice, //!< normal, but significant, condition
Log_Info, //!< informational
Log_Debug //!< debug level messages
};
/*! @fn RLogInit(int &argc, char **argv)
@brief Initializer for external rlog modules.
This should be called at the beginning of a program which uses RLog. If
it isn't called, the logging should still work anyway although some
external features may not.
This allows command line arguments to be passed to any rlog modules which
might want to examine them.
*/
void RLOG_DECL RLogInit(int &argc, char **argv);
// Get channel with a particular component name
RLOG_DECL RLogChannel *GetComponentChannel(const char *component,
const char *path,
LogLevel level = Log_Undef);
// the global channel receives messages for all components
RLOG_DECL RLogChannel *GetGlobalChannel( const char *path,
LogLevel level = Log_Undef);
/*! @def DEF_CHANNEL( const char *path, LogLevel level )
@brief Returns pointer to RLogChannel struct for the given path
@param path The hierarchical path to the channel. Elements in the path
are separated by '/'.
DEF_CHANNEL gets an existing (or defines a new) log type. For example
"debug", "warning", "error" are predefined types. You might define
completely new types, like "timing", or perhaps sub-types like
"debug/timing/foo", depending on your needs.
Reporting paths do not need to be unique within a project (or even a
file).
Channels form a hierarchy. If one subscribes to "debug", then you also
get messages posted to more specific types such as "debug/foo". But if
you subscribe to a more specific type, such as "debug/foo", then you will
not receive more general messages such as to "debug".
Example:
@code
#include <rlog/rlog.h>
#include <rlog/RLogChannel.h>
static RLogChannel *MyChannel = DEF_CHANNEL("me/mine/allmine",Log_Info);
func()
{
rLog( MyChannel, "this is being sent to my own channel" );
rLog( MyChannel, "%s %s", "hello", "world" );
}
main()
{
// log all messages to the "me" channel to stderr
StdioNode stdLog( STDERR_FILENO );
stdLog.subscribeTo( RLOG_CHANNEL ("me") );
func();
}
@endcode
@see test.cpp
*/
#define DEF_CHANNEL(path,level) RLOG_CHANNEL_IMPL(RLOG_COMPONENT, path, level)
#define RLOG_CHANNEL(path) RLOG_CHANNEL_IMPL(RLOG_COMPONENT, path, rlog::Log_Undef)
#define RLOG_CHANNEL_IMPL(COMPONENT,path,level) \
rlog::GetComponentChannel(STR(COMPONENT),path,level)
/*
Pre-defined channels,
"debug", "warning", and "error".
You can of course defined sub-channels based on the predefined types,
such as "debug/level1", or whatever.
*/
extern RLOG_DECL RLogChannel *_RLDebugChannel;
extern RLOG_DECL RLogChannel *_RLInfoChannel;
extern RLOG_DECL RLogChannel *_RLWarningChannel;
extern RLOG_DECL RLogChannel *_RLErrorChannel;
/*! @struct PublishLoc <rlog/rlog.h>
@brief Internal RLog structure - static struct for each rLog() statement
@internal
Structure created for each log location to keep track of logging state
and associated data.
Only static members are initialized at build time, which is why
RLogChannel is passed as argument. Otherwise entire structure will have
to be initialized at run-time which adds extra code and a guard variable
for the struct.
*/
struct PublishLoc
{
bool *enabled;
// If the compiler supports printf attribute specification on function
// pointers, we'll use it here so that the compiler knows to check for
// proper printf formatting. If it doesn't support it, then we'll
// force the check by inserting a bogus inline function..
//! function to call when we reach the log statement.
void (*publish)(PublishLoc *, RLogChannel *, const char *format, ... )
PRINTF_FP(3,4);
RLogNode *pub;
const char *component;
const char *fileName;
const char *functionName;
int lineNum;
RLogChannel *channel;
inline void enable() { *enabled = true; }
inline void disable() { *enabled = false; }
inline bool isEnabled() { return *enabled; }
~PublishLoc();
};
/*! @fn RLog_Register
@brief Internal RLog function - registers a log statement.
This is used by the rDebug(), rInfo(), rWarning(), rError() macros.
@internal
*/
void RLOG_DECL RLog_Register(PublishLoc *loc, RLogChannel *,
const char *format, ... ) PRINTF(3,4);
/*! @fn rAssertFailed
@brief Internal RLog function - helper function for rAssert macro.
@internal
*/
void RLOG_DECL rAssertFailed( const char *component, const char *file,
const char *function, int line,
const char *conditionStr );
// if we don't have printf attributes on function pointers, but we do have
// printf attributes, then make a bogus check function..
#if !HAVE_PRINTF_FP && HAVE_PRINTF_ATTR
void __checkArgs(int, const char *, ... ) PRINTF(2,3);
inline void __checkArgs(int, const char *, ...)
{ }
#endif
}
#if C99_VARIADAC_MACROS
#include <rlog/rlog-c99.h>
#elif PREC99_VARIADAC_MACROS
#include <rlog/rlog-prec99.h>
#else
#include <rlog/rlog-novariadic.h>
#endif
#define _rAssertFailed(COMPONENT, COND) \
rlog::rAssertFailed(STR(COMPONENT),__FILE__,__FUNCTION__,__LINE__, COND)
/*! @def rAssert( cond )
@brief Assert condition - throws error if @a cond evaluates to false.
Assert error condition. Displays error message if condition does not
evaluate to TRUE.
We throw an error from rAssertFailed. It isn't done inline so that we
don't have to include the STL exception code here and bloat callers that
don't use it or don't care.
*/
#define rAssert( cond ) \
do { \
if( unlikely((cond) == false) ) \
{ rError( "Assert failed: " STR(cond) ); \
_rAssertFailed(RLOG_COMPONENT, STR(cond)); \
} \
} while(0)
/*! @def rAssertSilent( cond )
@brief Assert condition - throws error if @a cond evaluates to false, but
does not display error message.
Assert error condition. Similar to rAssert except that it does not display
an error.
*/
#define rAssertSilent( cond ) \
do { \
if( unlikely((cond) == false) ) \
{ _rAssertFailed(RLOG_COMPONENT, STR(cond)); } \
} while(0)
/*! @}
*/
/* @def RLOG_NO_COPY
@brief Disables class copy constructor and operator =.
This macro declares a private copy constructor and assignment operator
which prevents automatic generation of these operation by the compiler.
Attention, it switches access to private, so use it only at the end of the
class declaration.
*/
#define RLOG_NO_COPY(CNAME) \
private: \
CNAME(const CNAME&); \
CNAME & operator = (const CNAME &)
#endif // rlog.h
|