Code Listener  [unstable] git snapshot
Macros | Functions
cl_msg.hh File Reference

Macros for emitting error, warning, info and debug messages through the code listener interface. More...

#include "code_listener.h"
#include <cstdlib>
#include <sstream>
#include <string>

Go to the source code of this file.

Macros

#define CL_DIE(msg)
 emit a fatal error message and ask the code listener peer to shoot down the process More...
 
#define CL_MSG_STREAM(fnc, to_stream)
 standard output stream wrapper on top of the code listener interface More...
 
#define CL_MSG_STREAM_INTERNAL(fnc, to_stream)
 wrapper around CL_MSG_STREAM decorating the message by internal location info More...
 
#define CL_DEBUG(to_stream)   CL_MSG_STREAM_INTERNAL(cl_debug, "debug: " << to_stream)
 emit a debug message with internal location info More...
 
#define CL_WARN(to_stream)   CL_MSG_STREAM_INTERNAL(cl_warn, "warning: " << to_stream)
 emit a warning message with internal location info More...
 
#define CL_ERROR(to_stream)   CL_MSG_STREAM_INTERNAL(cl_error, "error: " << to_stream)
 emit an error message with internal location info More...
 
#define CL_NOTE(to_stream)   CL_MSG_STREAM_INTERNAL(cl_note, "note: " << to_stream)
 emit a note message with internal location info More...
 
#define CL_DEBUG_MSG(loc, what)   CL_MSG_STREAM(cl_debug, *(loc) << "debug: " << what)
 emit a debug message using the given location info More...
 
#define CL_WARN_MSG(loc, what)   CL_MSG_STREAM(cl_warn, *(loc) << "warning: " << what)
 emit a warning message using the given location info More...
 
#define CL_ERROR_MSG(loc, what)   CL_MSG_STREAM(cl_error, *(loc) << "error: " << what)
 emit an error message using the given location info More...
 
#define CL_NOTE_MSG(loc, what)   CL_MSG_STREAM(cl_note, *(loc) << "note: " << what)
 emit a note message using the given location info More...
 
#define CL_DEBUG_AT(level, what)
 same as CL_DEBUG, but compares the current debug level with the given one More...
 
#define CL_DEBUG_MSG_AT(level, loc, what)
 same as CL_DEBUG_MSG, but compares current debug level with the given one More...
 

Functions

std::ostream & operator<< (std::ostream &str, const struct cl_loc &loc)
 
void cl_debug (const char *msg)
 emit raw debug message More...
 
void cl_warn (const char *msg)
 emit raw warning message More...
 
void cl_error (const char *msg)
 emit raw error message More...
 
void cl_note (const char *msg)
 emit raw note message More...
 
void cl_die (const char *msg)
 emit raw fatal error and ask cl peer to shoot down the process More...
 
int cl_debug_level (void)
 current debugging level More...
 

Detailed Description

Macros for emitting error, warning, info and debug messages through the code listener interface.

Definition in file cl_msg.hh.

Macro Definition Documentation

#define CL_DEBUG (   to_stream)    CL_MSG_STREAM_INTERNAL(cl_debug, "debug: " << to_stream)

emit a debug message with internal location info

Definition at line 75 of file cl_msg.hh.

#define CL_DEBUG_AT (   level,
  what 
)
Value:
do { \
if (cl_debug_level() < (level)) \
break; \
CL_DEBUG(what); \
} while (0)

same as CL_DEBUG, but compares the current debug level with the given one

Definition at line 129 of file cl_msg.hh.

#define CL_DEBUG_MSG (   loc,
  what 
)    CL_MSG_STREAM(cl_debug, *(loc) << "debug: " << what)

emit a debug message using the given location info

Parameters
loclocation info to use
whatwhatever you need to stream out

Definition at line 101 of file cl_msg.hh.

#define CL_DEBUG_MSG_AT (   level,
  loc,
  what 
)
Value:
do { \
if (cl_debug_level() < (level)) \
break; \
CL_DEBUG_MSG(loc, what); \
} while (0)

same as CL_DEBUG_MSG, but compares current debug level with the given one

Definition at line 137 of file cl_msg.hh.

#define CL_DIE (   msg)
Value:
do { \
cl_die("fatal error: " msg "\n"); \
abort(); \
} while (0)

emit a fatal error message and ask the code listener peer to shoot down the process

Parameters
msga message to emit before the process dies, it must be a string literal

Definition at line 41 of file cl_msg.hh.

#define CL_ERROR (   to_stream)    CL_MSG_STREAM_INTERNAL(cl_error, "error: " << to_stream)

emit an error message with internal location info

Definition at line 87 of file cl_msg.hh.

#define CL_ERROR_MSG (   loc,
  what 
)    CL_MSG_STREAM(cl_error, *(loc) << "error: " << what)

emit an error message using the given location info

Parameters
loclocation info to use
whatwhatever you need to stream out

Definition at line 117 of file cl_msg.hh.

#define CL_MSG_STREAM (   fnc,
  to_stream 
)
Value:
do { \
if ((cl_debug == (fnc)) && !cl_debug_level()) \
break; \
\
std::ostringstream str; \
str << to_stream; \
fnc(str.str().c_str()); \
} while (0)

standard output stream wrapper on top of the code listener interface

Parameters
fnca function used to emit the message - cl_debug(), cl_warn(), cl_error() or cl_note()
to_streamwhatever you need to stream out. Stuff with defined operator<<(std::ostream, ...) is a viable start.

Definition at line 53 of file cl_msg.hh.

#define CL_MSG_STREAM_INTERNAL (   fnc,
  to_stream 
)
Value:
CL_MSG_STREAM(fnc, __FILE__ << ":" << __LINE__ \
<< ": " << to_stream << " [internal location]")

wrapper around CL_MSG_STREAM decorating the message by internal location info

see cl_msg.hh::CL_MSG_STREAM for details

Definition at line 68 of file cl_msg.hh.

#define CL_NOTE (   to_stream)    CL_MSG_STREAM_INTERNAL(cl_note, "note: " << to_stream)

emit a note message with internal location info

Definition at line 93 of file cl_msg.hh.

#define CL_NOTE_MSG (   loc,
  what 
)    CL_MSG_STREAM(cl_note, *(loc) << "note: " << what)

emit a note message using the given location info

Parameters
loclocation info to use
whatwhatever you need to stream out

Definition at line 125 of file cl_msg.hh.

#define CL_WARN (   to_stream)    CL_MSG_STREAM_INTERNAL(cl_warn, "warning: " << to_stream)

emit a warning message with internal location info

Definition at line 81 of file cl_msg.hh.

#define CL_WARN_MSG (   loc,
  what 
)    CL_MSG_STREAM(cl_warn, *(loc) << "warning: " << what)

emit a warning message using the given location info

Parameters
loclocation info to use
whatwhatever you need to stream out

Definition at line 109 of file cl_msg.hh.

Function Documentation

void cl_debug ( const char *  msg)

emit raw debug message

Parameters
[in]msgThe message to be emitted
int cl_debug_level ( void  )

current debugging level

Returns
Current debugging level
void cl_die ( const char *  msg)

emit raw fatal error and ask cl peer to shoot down the process

Parameters
[in]msgThe message to be emitted
void cl_error ( const char *  msg)

emit raw error message

Parameters
[in]msgThe message to be emitted
void cl_note ( const char *  msg)

emit raw note message

Parameters
[in]msgThe message to be emitted
void cl_warn ( const char *  msg)

emit raw warning message

Parameters
[in]msgThe message to be emitted
std::ostream& operator<< ( std::ostream &  str,
const struct cl_loc loc 
)
inline

Definition at line 144 of file cl_msg.hh.

References cl_loc::column, cl_loc::file, and cl_loc::line.