luna-sysmgr-common
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Logging.h File Reference
#include "Common.h"
#include <stdio.h>
#include <glib.h>
#include <PmLogLib.h>
Include dependency graph for Logging.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SYSMGR_TRACE()
 
#define luna_log(channel,...)
 
#define luna_warn(channel,...)
 
#define luna_critical(channel,...)
 
#define luna_assert(val)
 
#define LunaLogContext   PmLogContext
 
#define luna_syslog(context, level, message)   PmLogPrint((PmLogContext) context, GLogToPmLogLevel(level), "%s", message)
 
#define luna_syslogV(context, level,...)   PmLogPrint((PmLogContext) context, GLogToPmLogLevel(level), __VA_ARGS__)
 
#define VERIFY(t)   (G_LIKELY(t) || (logFailedVerify(#t, __FILE__, __LINE__, __FUNCTION__), false))
 Test macro that will make a critical log entry if the test fails. More...
 
#define CHECK(t)   (G_LIKELY(t) || (logCheck(#t, __FILE__, __LINE__, __FUNCTION__), false))
 Test macro that will make a warning log entry if the test fails. More...
 
#define FAILURE(m)   logFailure(m, __FILE__, __LINE__, __FUNCTION__)
 Direct critical message to put in the logs with file & line number, with filtering of repeats. More...
 
#define SHOULD_NOT_REACH_HERE   FAILURE("This line should never be reached")
 

Functions

bool LunaChannelEnabled (const char *channel)
 
PmLogLevel GLogToPmLogLevel (GLogLevelFlags flags)
 
LunaLogContext syslogContextGlobal ()
 
LunaLogContext syslogContextJavascript ()
 
void logInit ()
 
void logFilter (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer unused_data)
 
void logFailedVerify (const gchar *test, const gchar *file, int line, const gchar *function)
 Functions that implement the macros above. You probably don't want to call them directly... More...
 
void logFailure (const gchar *message, const gchar *file, int line, const gchar *function)
 
void logCheck (const gchar *message, const gchar *file, int line, const gchar *function)
 

Macro Definition Documentation

#define CHECK (   t)    (G_LIKELY(t) || (logCheck(#t, __FILE__, __LINE__, __FUNCTION__), false))

Test macro that will make a warning log entry if the test fails.

#define FAILURE (   m)    logFailure(m, __FILE__, __LINE__, __FUNCTION__)

Direct critical message to put in the logs with file & line number, with filtering of repeats.

#define luna_assert (   val)
Value:
do { \
if (G_LIKELY(val)) {} \
else { \
g_critical("FATAL:(%s:%d) %s", __PRETTY_FUNCTION__, __LINE__, #val); \
int* p = 0; \
*p = 0; \
} \
} while(0) \
#define luna_critical (   channel,
  ... 
)
Value:
do { \
fprintf(stdout, "CRITICAL<%s>:(%s:%d) ", channel, __PRETTY_FUNCTION__, __LINE__); \
fprintf(stdout, __VA_ARGS__); \
fprintf(stdout, "\n"); \
} while(0)
#define luna_log (   channel,
  ... 
)
Value:
do { \
if (LunaChannelEnabled(channel)) { \
fprintf(stdout, "LOG<%s>:(%s:%d) ", channel, __PRETTY_FUNCTION__, __LINE__); \
fprintf(stdout, __VA_ARGS__); \
fprintf(stdout, "\n"); \
} \
} while(0)
#define luna_syslog (   context,
  level,
  message 
)    PmLogPrint((PmLogContext) context, GLogToPmLogLevel(level), "%s", message)
#define luna_syslogV (   context,
  level,
  ... 
)    PmLogPrint((PmLogContext) context, GLogToPmLogLevel(level), __VA_ARGS__)
#define luna_warn (   channel,
  ... 
)
Value:
do { \
if (LunaChannelEnabled(channel)) { \
fprintf(stdout, "WARN<%s>:(%s:%d) ", channel, __PRETTY_FUNCTION__, __LINE__); \
fprintf(stdout, __VA_ARGS__); \
fprintf(stdout, "\n"); \
} \
} while(0)
#define LunaLogContext   PmLogContext
#define SHOULD_NOT_REACH_HERE   FAILURE("This line should never be reached")
#define SYSMGR_TRACE ( )
#define VERIFY (   t)    (G_LIKELY(t) || (logFailedVerify(#t, __FILE__, __LINE__, __FUNCTION__), false))

Test macro that will make a critical log entry if the test fails.

Function Documentation

PmLogLevel GLogToPmLogLevel ( GLogLevelFlags  flags)
void logCheck ( const gchar *  message,
const gchar *  file,
int  line,
const gchar *  function 
)
void logFailedVerify ( const gchar *  test,
const gchar *  file,
int  line,
const gchar *  function 
)

Functions that implement the macros above. You probably don't want to call them directly...

void logFailure ( const gchar *  message,
const gchar *  file,
int  line,
const gchar *  function 
)
void logFilter ( const gchar *  log_domain,
GLogLevelFlags  log_level,
const gchar *  message,
gpointer  unused_data 
)
void logInit ( )
bool LunaChannelEnabled ( const char *  channel)
LunaLogContext syslogContextGlobal ( )
LunaLogContext syslogContextJavascript ( )