10 #ifndef PCMK__CRM_COMMON_LOGGING__H    11 #define PCMK__CRM_COMMON_LOGGING__H    17 #include <libxml/tree.h>    38 #define LOG_TRACE   (LOG_DEBUG+1)    43 #define LOG_STDOUT  254    75 gboolean 
crm_log_init(
const char *entity, uint8_t level, gboolean daemon,
    76                       gboolean to_stderr, 
int argc, 
char **argv, gboolean quiet);
    79 void crm_log_output_fn(
const char *file, 
const char *
function, 
int line, 
int level,
    80                        const char *prefix, 
const char *output);
    83 #define crm_log_output(level, prefix, output)   \    84     crm_log_output_fn(__FILE__, __func__, __LINE__, level, prefix, output)    98 void pcmk_log_xml_as(
const char *file, 
const char *
function, uint32_t line,
    99                      uint32_t tags, uint8_t level, 
const char *text,
   107 #if defined(__clang__)   108 #define CRM_TRACE_INIT_DATA(name)   111 #define CRM_TRACE_INIT_DATA(name) QB_LOG_INIT_DATA(name)   126 static inline uint8_t
   127 pcmk__clip_log_level(
int level)
   132     if (level >= UINT8_MAX) {
   149 #define do_crm_log(level, fmt, args...) do {                                \   150         uint8_t _level = pcmk__clip_log_level(level);                       \   154                 printf(fmt "\n" , ##args);                                  \   159                 qb_log_from_external_source(__func__, __FILE__, fmt,        \   160                                             _level, __LINE__, 0 , ##args);  \   174 #define do_crm_log_unlikely(level, fmt, args...) do {                       \   175         uint8_t _level = pcmk__clip_log_level(level);                       \   178             case LOG_STDOUT: case LOG_NEVER:                                \   181                 static struct qb_log_callsite *trace_cs = NULL;             \   182                 if (trace_cs == NULL) {                                     \   183                     trace_cs = qb_log_callsite_get(__func__, __FILE__, fmt, \   184                                                    _level, __LINE__, 0);    \   186                 if (crm_is_callsite_active(trace_cs, _level, 0)) {          \   187                     qb_log_from_external_source(__func__, __FILE__, fmt,    \   188                                                 _level, __LINE__, 0 ,       \   196 #define CRM_LOG_ASSERT(expr) do {                                       \   198             static struct qb_log_callsite *core_cs = NULL;              \   199             if(core_cs == NULL) {                                       \   200                 core_cs = qb_log_callsite_get(__func__, __FILE__,       \   201                                               "log-assert", LOG_TRACE,  \   204             crm_abort(__FILE__, __func__, __LINE__, #expr,              \   205                       core_cs?core_cs->targets:FALSE, TRUE);            \   213 #define CRM_CHECK(expr, failure_action) do {                            \   215             static struct qb_log_callsite *core_cs = NULL;              \   216             if (core_cs == NULL) {                                      \   217                 core_cs = qb_log_callsite_get(__func__, __FILE__,       \   219                                               LOG_TRACE, __LINE__, 0);  \   221             crm_abort(__FILE__, __func__, __LINE__, #expr,              \   222                 (core_cs? core_cs->targets: FALSE), TRUE);              \   236 #define do_crm_log_xml(level, text, xml) do {                           \   237         uint8_t _level = pcmk__clip_log_level(level);                   \   238         static struct qb_log_callsite *xml_cs = NULL;                   \   245                 if (xml_cs == NULL) {                                   \   246                     xml_cs = qb_log_callsite_get(__func__, __FILE__,    \   247                                                  "xml-blob", _level,    \   250                 if (crm_is_callsite_active(xml_cs, _level, 0)) {        \   251                     pcmk_log_xml_as(__FILE__, __func__, __LINE__, 0,    \   252                                     _level, text, (xml));               \   268 #define do_crm_log_alias(level, file, function, line, fmt, args...) do {    \   269         uint8_t _level = pcmk__clip_log_level(level);                       \   273                 printf(fmt "\n" , ##args);                                  \   278                 qb_log_from_external_source(function, file, fmt, _level,    \   299 #define crm_perror(level, fmt, args...) do {                                \   300         uint8_t _level = pcmk__clip_log_level(level);                       \   306                 const char *err = strerror(errno);                          \   307                 if (_level <= crm_log_level) {                              \   308                     fprintf(stderr, fmt ": %s (%d)\n" , ##args, err,        \   314                 do_crm_log((level), fmt ": %s (%d)" , ##args, err, errno);  \   330 #define crm_log_tag(level, tag, fmt, args...) do {                          \   331         uint8_t _level = pcmk__clip_log_level(level);                       \   334             case LOG_STDOUT: case LOG_NEVER:                                \   337                 static struct qb_log_callsite *trace_tag_cs = NULL;         \   338                 int converted_tag = g_quark_try_string(tag);                \   339                 if (trace_tag_cs == NULL) {                                 \   340                     trace_tag_cs = qb_log_callsite_get(__func__, __FILE__,  \   345                 if (crm_is_callsite_active(trace_tag_cs, _level,            \   347                     qb_log_from_external_source(__func__, __FILE__, fmt,    \   349                                                 converted_tag , ##args);    \   355 #define crm_emerg(fmt, args...)   qb_log(LOG_EMERG,       fmt , ##args)   356 #define crm_crit(fmt, args...)    qb_logt(LOG_CRIT,    0, fmt , ##args)   359 #define crm_err(fmt, args...)     qb_logt(LOG_ERR,     0, fmt , ##args)   362 #define crm_warn(fmt, args...)    qb_logt(LOG_WARNING, 0, fmt , ##args)   365 #define crm_notice(fmt, args...)  qb_logt(LOG_NOTICE,  0, fmt , ##args)   367 #define crm_info(fmt, args...)    qb_logt(LOG_INFO,    0, fmt , ##args)   370 #define crm_debug(fmt, args...)   do_crm_log_unlikely(LOG_DEBUG, fmt , ##args)   372 #define crm_trace(fmt, args...)   do_crm_log_unlikely(LOG_TRACE, fmt , ##args)   374 #define crm_log_xml_crit(xml, text)    do_crm_log_xml(LOG_CRIT,    text, xml)   375 #define crm_log_xml_err(xml, text)     do_crm_log_xml(LOG_ERR,     text, xml)   376 #define crm_log_xml_warn(xml, text)    do_crm_log_xml(LOG_WARNING, text, xml)   377 #define crm_log_xml_notice(xml, text)  do_crm_log_xml(LOG_NOTICE,  text, xml)   378 #define crm_log_xml_info(xml, text)    do_crm_log_xml(LOG_INFO,    text, xml)   379 #define crm_log_xml_debug(xml, text)   do_crm_log_xml(LOG_DEBUG,   text, xml)   380 #define crm_log_xml_trace(xml, text)   do_crm_log_xml(LOG_TRACE,   text, xml)   382 #define crm_log_xml_explicit(xml, text)  do {                   \   383         static struct qb_log_callsite *digest_cs = NULL;        \   384         digest_cs = qb_log_callsite_get(                        \   385             __func__, __FILE__, text, LOG_TRACE, __LINE__,      \   387         if (digest_cs && digest_cs->targets) {                  \   388             do_crm_log_xml(LOG_TRACE,   text, xml);             \   396 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1) void crm_enable_stderr(int enable)
 
void pcmk_log_xml_as(const char *file, const char *function, uint32_t line, uint32_t tags, uint8_t level, const char *text, const xmlNode *xml)
Log XML line-by-line in a formatted fashion. 
 
gboolean crm_log_init(const char *entity, uint8_t level, gboolean daemon, gboolean to_stderr, int argc, char **argv, gboolean quiet)
 
unsigned int crm_trace_nonlog
 
void crm_bump_log_level(int argc, char **argv)
Make logging more verbose. 
 
void crm_log_deinit(void)
 
void crm_log_output_fn(const char *file, const char *function, int line, int level, const char *prefix, const char *output)
 
void crm_enable_blackbox(int nsig)
 
void crm_log_args(int argc, char **argv)
Log the command line (once) 
 
void crm_write_blackbox(int nsig, const struct qb_log_callsite *callsite)
 
unsigned int set_crm_log_level(unsigned int level)
 
gboolean crm_is_callsite_active(struct qb_log_callsite *cs, uint8_t level, uint32_t tags)
 
unsigned int get_crm_log_level(void)
 
unsigned int crm_log_level
 
void crm_disable_blackbox(int nsig)
 
void crm_log_preinit(const char *entity, int argc, char *const *argv)
Initializes the logging system and defaults to the least verbose output level. 
 
void crm_update_callsites(void)