rlog.h File Reference

Defines macros for debug, warning, and error messages. More...

#include <rlog/common.h>
#include <rlog/rlog-c99.h>

Go to the source code of this file.

Namespaces

namespace  rlog

Classes

struct  rlog::PublishLoc
 Internal RLog structure - static struct for each rLog() statement. More...

Defines

#define CONCAT2(A, B)   A##B
#define CONCAT(A, B)   CONCAT2(A,B)
#define STR(X)   #X
#define CURRENT_RLOG_VERSION   20040503
#define DEF_CHANNEL(path, level)   RLOG_CHANNEL_IMPL(RLOG_COMPONENT, path, level)
 Returns pointer to RLogChannel struct for the given path.
#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)
#define _rAssertFailed(COMPONENT, COND)   rlog::rAssertFailed(STR(COMPONENT),__FILE__,__FUNCTION__,__LINE__, COND)
#define rAssert(cond)
 Assert condition - throws error if cond evaluates to false.
#define rAssertSilent(cond)
 Assert condition - throws error if cond evaluates to false, but does not display error message.
#define RLOG_NO_COPY(CNAME)

Enumerations

enum  LogLevel {
  rlog::Log_Undef = 0, rlog::Log_Critical, rlog::Log_Error, rlog::Log_Warning,
  rlog::Log_Notice, rlog::Log_Info, rlog::Log_Debug
}

Functions

int RLogVersion ()
void RLOG_DECL rlog::RLogInit (int &argc, char **argv)
 Initializer for external rlog modules.
RLOG_DECL RLogChannel * rlog::GetComponentChannel (const char *component, const char *path, LogLevel level=Log_Undef)
RLOG_DECL RLogChannel * rlog::GetGlobalChannel (const char *path, LogLevel level=Log_Undef)
void rlog::RLog_Register (PublishLoc *loc, RLogChannel *channel, const char *format,...)
void rlog::rAssertFailed (const char *component, const char *file, const char *function, int line, const char *conditionStr)

Variables

RLOG_DECL RLogChannelrlog::_RLDebugChannel
RLOG_DECL RLogChannelrlog::_RLInfoChannel
RLOG_DECL RLogChannelrlog::_RLWarningChannel
RLOG_DECL RLogChannelrlog::_RLErrorChannel


Detailed Description

Defines macros for debug, warning, and error messages.


Define Documentation

#define DEF_CHANNEL ( path,
level   )     RLOG_CHANNEL_IMPL(RLOG_COMPONENT, path, level)

Returns pointer to RLogChannel struct for the given path.

Parameters:
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:

      #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();
      }

See also:
test.cpp

#define rAssert ( cond   ) 

Value:

do { \
        if( unlikely((cond) == false) ) \
        { rError( "Assert failed: " STR(cond) ); \
          _rAssertFailed(RLOG_COMPONENT, STR(cond)); \
        } \
    } while(0)
Assert condition - throws error if 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 rAssertSilent ( cond   ) 

Value:

do { \
        if( unlikely((cond) == false) ) \
        { _rAssertFailed(RLOG_COMPONENT, STR(cond)); } \
    } while(0)
Assert condition - throws error if 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 RLOG_NO_COPY ( CNAME   ) 

Value:

private: \
        CNAME(const CNAME&); \
        CNAME & operator = (const CNAME &)


Generated on Mon Nov 20 22:57:44 2006 for rlog by  doxygen 1.5.0