pacemaker  2.0.2-debe490
Scalable High-Availability cluster resource manager
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Enumerations | Functions | Variables
logging.h File Reference

Wrappers for and extensions to libqb logging. More...

#include <qb/qblog.h>
#include <assert.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 CRM_LOGGING__H
 
#define LOG_TRACE   LOG_DEBUG+1
 
#define CRM_XS   "|"
 
#define crm_log_output(level, prefix, output)   crm_log_output_fn(__FILE__, __FUNCTION__, __LINE__, level, prefix, output)
 
#define CRM_TRACE_INIT_DATA(name)   QB_LOG_INIT_DATA(name)
 
#define do_crm_log(level, fmt, args...)   qb_log_from_external_source(__func__, __FILE__, fmt, level, __LINE__, 0 , ##args)
 Log a message. More...
 
#define do_crm_log_unlikely(level, fmt, args...)
 Log a message that is likely to be filtered out. More...
 
#define CRM_LOG_ASSERT(expr)
 
#define CRM_CHECK(expr, failure_action)
 
#define do_crm_log_xml(level, text, xml)
 
#define do_crm_log_alias(level, file, function, line, fmt, args...)
 Log a message as if it came from a different code location. More...
 
#define do_crm_log_always(level, fmt, args...)   qb_log(level, fmt , ##args)
 Log a message using constant severity. More...
 
#define crm_perror(level, fmt, args...)
 Log a system error message. More...
 
#define crm_log_tag(level, tag, fmt, args...)
 
#define crm_crit(fmt, args...)   qb_logt(LOG_CRIT, 0, fmt , ##args)
 
#define crm_err(fmt, args...)   qb_logt(LOG_ERR, 0, fmt , ##args)
 
#define crm_warn(fmt, args...)   qb_logt(LOG_WARNING, 0, fmt , ##args)
 
#define crm_notice(fmt, args...)   qb_logt(LOG_NOTICE, 0, fmt , ##args)
 
#define crm_info(fmt, args...)   qb_logt(LOG_INFO, 0, fmt , ##args)
 
#define crm_debug(fmt, args...)   do_crm_log_unlikely(LOG_DEBUG, fmt , ##args)
 
#define crm_trace(fmt, args...)   do_crm_log_unlikely(LOG_TRACE, fmt , ##args)
 
#define crm_log_xml_crit(xml, text)   do_crm_log_xml(LOG_CRIT, text, xml)
 
#define crm_log_xml_err(xml, text)   do_crm_log_xml(LOG_ERR, text, xml)
 
#define crm_log_xml_warn(xml, text)   do_crm_log_xml(LOG_WARNING, text, xml)
 
#define crm_log_xml_notice(xml, text)   do_crm_log_xml(LOG_NOTICE, text, xml)
 
#define crm_log_xml_info(xml, text)   do_crm_log_xml(LOG_INFO, text, xml)
 
#define crm_log_xml_debug(xml, text)   do_crm_log_xml(LOG_DEBUG, text, xml)
 
#define crm_log_xml_trace(xml, text)   do_crm_log_xml(LOG_TRACE, text, xml)
 
#define crm_log_xml_explicit(xml, text)
 
#define crm_str(x)   (const char*)(x?x:"<null>")
 

Enumerations

enum  xml_log_options {
  xml_log_option_filtered = 0x0001, xml_log_option_formatted = 0x0002, xml_log_option_text = 0x0004, xml_log_option_diff_plus = 0x0010,
  xml_log_option_diff_minus = 0x0020, xml_log_option_diff_short = 0x0040, xml_log_option_diff_all = 0x0100, xml_log_option_dirty_add = 0x1000,
  xml_log_option_open = 0x2000, xml_log_option_children = 0x4000, xml_log_option_close = 0x8000
}
 

Functions

void crm_enable_blackbox (int nsig)
 
void crm_disable_blackbox (int nsig)
 
void crm_write_blackbox (int nsig, struct qb_log_callsite *callsite)
 
void crm_update_callsites (void)
 
void crm_log_deinit (void)
 
gboolean crm_log_cli_init (const char *entity)
 
void crm_log_preinit (const char *entity, int argc, char **argv)
 
gboolean crm_log_init (const char *entity, uint8_t level, gboolean daemon, gboolean to_stderr, int argc, char **argv, gboolean quiet)
 
void crm_log_args (int argc, char **argv)
 
void crm_log_output_fn (const char *file, const char *function, int line, int level, const char *prefix, const char *output)
 
gboolean crm_add_logfile (const char *filename)
 
void crm_bump_log_level (int argc, char **argv)
 
void crm_enable_stderr (int enable)
 
gboolean crm_is_callsite_active (struct qb_log_callsite *cs, uint8_t level, uint32_t tags)
 
void log_data_element (int log_level, const char *file, const char *function, int line, const char *prefix, xmlNode *data, int depth, gboolean formatted)
 
unsigned int set_crm_log_level (unsigned int level)
 
unsigned int get_crm_log_level (void)
 

Variables

unsigned int crm_log_level
 
gboolean crm_config_error
 
gboolean crm_config_warning
 
unsigned int crm_trace_nonlog
 

Detailed Description

Wrappers for and extensions to libqb logging.

Definition in file logging.h.

Macro Definition Documentation

#define CRM_CHECK (   expr,
  failure_action 
)
Value:
do { \
if(__unlikely((expr) == FALSE)) { \
static struct qb_log_callsite *core_cs = NULL; \
if(core_cs == NULL) { \
core_cs = qb_log_callsite_get(__func__, __FILE__, "check-assert", LOG_TRACE, __LINE__, 0); \
} \
crm_abort(__FILE__, __FUNCTION__, __LINE__, #expr, \
core_cs?core_cs->targets:FALSE, TRUE); \
failure_action; \
} \
} while(0)
#define LOG_TRACE
Definition: logging.h:26
void crm_abort(const char *file, const char *function, int line, const char *condition, gboolean do_core, gboolean do_fork)
Definition: utils.c:625
#define __unlikely(expr)
Definition: crm.h:47

Definition at line 156 of file logging.h.

#define crm_crit (   fmt,
  args... 
)    qb_logt(LOG_CRIT, 0, fmt , ##args)

Definition at line 239 of file logging.h.

#define crm_debug (   fmt,
  args... 
)    do_crm_log_unlikely(LOG_DEBUG, fmt , ##args)

Definition at line 245 of file logging.h.

#define crm_err (   fmt,
  args... 
)    qb_logt(LOG_ERR, 0, fmt , ##args)

Definition at line 240 of file logging.h.

#define crm_info (   fmt,
  args... 
)    qb_logt(LOG_INFO, 0, fmt , ##args)

Definition at line 243 of file logging.h.

#define CRM_LOG_ASSERT (   expr)
Value:
do { \
if(__unlikely((expr) == FALSE)) { \
static struct qb_log_callsite *core_cs = NULL; \
if(core_cs == NULL) { \
core_cs = qb_log_callsite_get(__func__, __FILE__, "log-assert", LOG_TRACE, __LINE__, 0); \
} \
crm_abort(__FILE__, __FUNCTION__, __LINE__, #expr, \
core_cs?core_cs->targets:FALSE, TRUE); \
} \
} while(0)
#define LOG_TRACE
Definition: logging.h:26
void crm_abort(const char *file, const char *function, int line, const char *condition, gboolean do_core, gboolean do_fork)
Definition: utils.c:625
#define __unlikely(expr)
Definition: crm.h:47

Definition at line 142 of file logging.h.

#define crm_log_output (   level,
  prefix,
  output 
)    crm_log_output_fn(__FILE__, __FUNCTION__, __LINE__, level, prefix, output)

Definition at line 84 of file logging.h.

#define crm_log_tag (   level,
  tag,
  fmt,
  args... 
)
Value:
do { \
static struct qb_log_callsite *trace_tag_cs = NULL; \
int converted_tag = g_quark_try_string(tag); \
if(trace_tag_cs == NULL) { \
trace_tag_cs = qb_log_callsite_get(__func__, __FILE__, fmt, level, __LINE__, converted_tag); \
} \
if (crm_is_callsite_active(trace_tag_cs, level, converted_tag)) { \
qb_log_from_external_source(__func__, __FILE__, fmt, level, \
__LINE__, converted_tag , ##args); \
} \
} while(0)
gboolean crm_is_callsite_active(struct qb_log_callsite *cs, uint8_t level, uint32_t tags)
Definition: logging.c:624

Definition at line 227 of file logging.h.

#define crm_log_xml_crit (   xml,
  text 
)    do_crm_log_xml(LOG_CRIT, text, xml)

Definition at line 248 of file logging.h.

#define crm_log_xml_debug (   xml,
  text 
)    do_crm_log_xml(LOG_DEBUG, text, xml)

Definition at line 253 of file logging.h.

#define crm_log_xml_err (   xml,
  text 
)    do_crm_log_xml(LOG_ERR, text, xml)

Definition at line 249 of file logging.h.

#define crm_log_xml_explicit (   xml,
  text 
)
Value:
do { \
static struct qb_log_callsite *digest_cs = NULL; \
digest_cs = qb_log_callsite_get( \
__func__, __FILE__, text, LOG_TRACE, __LINE__, \
if (digest_cs && digest_cs->targets) { \
do_crm_log_xml(LOG_TRACE, text, xml); \
} \
} while(0)
#define LOG_TRACE
Definition: logging.h:26
unsigned int crm_trace_nonlog
Definition: logging.c:39
#define do_crm_log_xml(level, text, xml)
Definition: logging.h:168

Definition at line 256 of file logging.h.

#define crm_log_xml_info (   xml,
  text 
)    do_crm_log_xml(LOG_INFO, text, xml)

Definition at line 252 of file logging.h.

#define crm_log_xml_notice (   xml,
  text 
)    do_crm_log_xml(LOG_NOTICE, text, xml)

Definition at line 251 of file logging.h.

#define crm_log_xml_trace (   xml,
  text 
)    do_crm_log_xml(LOG_TRACE, text, xml)

Definition at line 254 of file logging.h.

#define crm_log_xml_warn (   xml,
  text 
)    do_crm_log_xml(LOG_WARNING, text, xml)

Definition at line 250 of file logging.h.

#define CRM_LOGGING__H

Definition at line 21 of file logging.h.

#define crm_notice (   fmt,
  args... 
)    qb_logt(LOG_NOTICE, 0, fmt , ##args)

Definition at line 242 of file logging.h.

#define crm_perror (   level,
  fmt,
  args... 
)
Value:
do { \
const char *err = strerror(errno); \
/* cast to int makes coverity happy when level == 0 */ \
if (level <= (int)crm_log_level) { \
fprintf(stderr, fmt ": %s (%d)\n" , ##args, err, errno); \
} \
do_crm_log(level, fmt ": %s (%d)" , ##args, err, errno); \
} while(0)
char * strerror(int errnum)
#define do_crm_log(level, fmt, args...)
Log a message.
Definition: logging.h:121
unsigned int crm_log_level
Definition: logging.c:37

Log a system error message.

Parameters
[in]levelSeverity at which to log the message
[in]fmtprintf-style format string for message
[in]argsAny arguments needed by format string
Note
Because crm_perror() adds the system error message and error number onto the end of fmt, that information will become extended information if CRM_XS is used inside fmt and will not show up in syslog.

Definition at line 218 of file logging.h.

#define crm_str (   x)    (const char*)(x?x:"<null>")

Definition at line 266 of file logging.h.

#define crm_trace (   fmt,
  args... 
)    do_crm_log_unlikely(LOG_TRACE, fmt , ##args)

Definition at line 246 of file logging.h.

#define CRM_TRACE_INIT_DATA (   name)    QB_LOG_INIT_DATA(name)

Definition at line 111 of file logging.h.

#define crm_warn (   fmt,
  args... 
)    qb_logt(LOG_WARNING, 0, fmt , ##args)

Definition at line 241 of file logging.h.

#define CRM_XS   "|"

Definition at line 34 of file logging.h.

#define do_crm_log (   level,
  fmt,
  args... 
)    qb_log_from_external_source(__func__, __FILE__, fmt, level, __LINE__, 0 , ##args)

Log a message.

Parameters
[in]levelSeverity at which to log the message
[in]fmtprintf-style format string for message
[in]argsAny arguments needed by format string

Definition at line 121 of file logging.h.

#define do_crm_log_alias (   level,
  file,
  function,
  line,
  fmt,
  args... 
)
Value:
do { \
if(level > 0) { \
qb_log_from_external_source(function, file, fmt, level, line, 0 , ##args); \
} else { \
printf(fmt "\n" , ##args); \
} \
} while(0)

Log a message as if it came from a different code location.

Parameters
[in]levelSeverity at which to log the message
[in]fileSource file name to use instead of FILE
[in]functionSource function name to use instead of func
[in]lineSource line number to use instead of line
[in]fmtprintf-style format string for message
[in]argsAny arguments needed by format string

Definition at line 188 of file logging.h.

#define do_crm_log_always (   level,
  fmt,
  args... 
)    qb_log(level, fmt , ##args)

Log a message using constant severity.

Parameters
[in]levelSeverity at which to log the message
[in]fmtprintf-style format string for message
[in]argsAny arguments needed by format string
Note
level and fmt /MUST/ be constants else compilation may fail

Definition at line 205 of file logging.h.

#define do_crm_log_unlikely (   level,
  fmt,
  args... 
)
Value:
do { \
static struct qb_log_callsite *trace_cs = NULL; \
if(trace_cs == NULL) { \
trace_cs = qb_log_callsite_get(__func__, __FILE__, fmt, level, __LINE__, 0); \
} \
if (crm_is_callsite_active(trace_cs, level, 0)) { \
qb_log_from_external_source( \
__func__, __FILE__, fmt, level, __LINE__, 0 , ##args); \
} \
} while(0)
gboolean crm_is_callsite_active(struct qb_log_callsite *cs, uint8_t level, uint32_t tags)
Definition: logging.c:624

Log a message that is likely to be filtered out.

Parameters
[in]levelSeverity at which to log the message
[in]fmtprintf-style format string for message
[in]argsAny arguments needed by format string

Definition at line 131 of file logging.h.

#define do_crm_log_xml (   level,
  text,
  xml 
)
Value:
do { \
static struct qb_log_callsite *xml_cs = NULL; \
if(xml_cs == NULL) { \
xml_cs = qb_log_callsite_get(__func__, __FILE__, "xml-blob", level, __LINE__, 0); \
} \
if (crm_is_callsite_active(xml_cs, level, 0)) { \
log_data_element(level, __FILE__, __FUNCTION__, __LINE__, text, xml, 1, xml_log_option_formatted); \
} \
} while(0)
void log_data_element(int log_level, const char *file, const char *function, int line, const char *prefix, xmlNode *data, int depth, gboolean formatted)
gboolean crm_is_callsite_active(struct qb_log_callsite *cs, uint8_t level, uint32_t tags)
Definition: logging.c:624

Definition at line 168 of file logging.h.

#define LOG_TRACE   LOG_DEBUG+1

Definition at line 26 of file logging.h.

Enumeration Type Documentation

Enumerator
xml_log_option_filtered 
xml_log_option_formatted 
xml_log_option_text 
xml_log_option_diff_plus 
xml_log_option_diff_minus 
xml_log_option_diff_short 
xml_log_option_diff_all 
xml_log_option_dirty_add 
xml_log_option_open 
xml_log_option_children 
xml_log_option_close 

Definition at line 52 of file logging.h.

Function Documentation

gboolean crm_add_logfile ( const char *  filename)

Definition at line 229 of file logging.c.

void crm_bump_log_level ( int  argc,
char **  argv 
)

Definition at line 961 of file logging.c.

void crm_disable_blackbox ( int  nsig)

Definition at line 441 of file logging.c.

void crm_enable_blackbox ( int  nsig)

Definition at line 435 of file logging.c.

void crm_enable_stderr ( int  enable)

Definition at line 949 of file logging.c.

gboolean crm_is_callsite_active ( struct qb_log_callsite *  cs,
uint8_t  level,
uint32_t  tags 
)

Definition at line 624 of file logging.c.

void crm_log_args ( int  argc,
char **  argv 
)

Definition at line 986 of file logging.c.

gboolean crm_log_cli_init ( const char *  entity)

Definition at line 514 of file logging.c.

void crm_log_deinit ( void  )

Definition at line 177 of file logging.c.

gboolean crm_log_init ( const char *  entity,
uint8_t  level,
gboolean  daemon,
gboolean  to_stderr,
int  argc,
char **  argv,
gboolean  quiet 
)

Definition at line 795 of file logging.c.

void crm_log_output_fn ( const char *  file,
const char *  function,
int  line,
int  level,
const char *  prefix,
const char *  output 
)

Definition at line 1018 of file logging.c.

void crm_log_preinit ( const char *  entity,
int  argc,
char **  argv 
)

Definition at line 739 of file logging.c.

void crm_update_callsites ( void  )

Definition at line 653 of file logging.c.

void crm_write_blackbox ( int  nsig,
struct qb_log_callsite *  callsite 
)

Definition at line 457 of file logging.c.

unsigned int get_crm_log_level ( void  )

Definition at line 979 of file logging.c.

void log_data_element ( int  log_level,
const char *  file,
const char *  function,
int  line,
const char *  prefix,
xmlNode *  data,
int  depth,
gboolean  formatted 
)
unsigned int set_crm_log_level ( unsigned int  level)

Definition at line 938 of file logging.c.

Variable Documentation

gboolean crm_config_error

Definition at line 59 of file utils.c.

gboolean crm_config_warning

Definition at line 60 of file utils.c.

unsigned int crm_log_level

Definition at line 37 of file logging.c.

unsigned int crm_trace_nonlog

Definition at line 39 of file logging.c.