10 #ifndef PCMK__CRM_COMMON_LOGGING__H 11 # define PCMK__CRM_COMMON_LOGGING__H 15 # include <qb/qblog.h> 16 # include <libxml/tree.h> 37 # define LOG_TRACE (LOG_DEBUG+1) 42 # define LOG_STDOUT 254 47 # define LOG_NEVER 255 53 # define crm_extended_logging(t, e) qb_log_ctl((t), QB_LOG_CONF_EXTENDED, (e)) 62 crm_extended_logging(
int t,
int e)
118 gboolean to_stderr,
int argc,
char **argv, gboolean quiet);
121 void crm_log_output_fn(
const char *file,
const char *
function,
int line,
int level,
122 const char *prefix,
const char *output);
125 #define crm_log_output(level, prefix, output) \ 126 crm_log_output_fn(__FILE__, __func__, __LINE__, level, prefix, output) 134 void log_data_element(
int log_level,
const char *file,
const char *
function,
135 int line,
const char *prefix,
const xmlNode *
data,
136 int depth, gboolean formatted);
148 #if defined(__clang__) 149 # define CRM_TRACE_INIT_DATA(name) 152 # define CRM_TRACE_INIT_DATA(name) QB_LOG_INIT_DATA(name) 168 # define do_crm_log(level, fmt, args...) do { \ 171 printf(fmt "\n" , ##args); \ 176 qb_log_from_external_source(__func__, __FILE__, fmt, \ 177 (level), __LINE__, 0 , ##args); \ 192 # define do_crm_log_unlikely(level, fmt, args...) do { \ 194 case LOG_STDOUT: case LOG_NEVER: \ 197 static struct qb_log_callsite *trace_cs = NULL; \ 198 if (trace_cs == NULL) { \ 199 trace_cs = qb_log_callsite_get(__func__, __FILE__, fmt, \ 200 (level), __LINE__, 0); \ 202 if (crm_is_callsite_active(trace_cs, (level), 0)) { \ 203 qb_log_from_external_source(__func__, __FILE__, fmt, \ 204 (level), __LINE__, 0 , ##args); \ 211 # define CRM_LOG_ASSERT(expr) do { \ 213 static struct qb_log_callsite *core_cs = NULL; \ 214 if(core_cs == NULL) { \ 215 core_cs = qb_log_callsite_get(__func__, __FILE__, \ 216 "log-assert", LOG_TRACE, \ 219 crm_abort(__FILE__, __func__, __LINE__, #expr, \ 220 core_cs?core_cs->targets:FALSE, TRUE); \ 227 # define CRM_CHECK(expr, failure_action) do { \ 229 static struct qb_log_callsite *core_cs = NULL; \ 230 if (core_cs == NULL) { \ 231 core_cs = qb_log_callsite_get(__func__, __FILE__, \ 233 LOG_TRACE, __LINE__, 0); \ 235 crm_abort(__FILE__, __func__, __LINE__, #expr, \ 236 (core_cs? core_cs->targets: FALSE), TRUE); \ 251 # define do_crm_log_xml(level, text, xml) do { \ 253 case LOG_STDOUT: case LOG_NEVER: \ 256 static struct qb_log_callsite *xml_cs = NULL; \ 257 if (xml_cs == NULL) { \ 258 xml_cs = qb_log_callsite_get(__func__, __FILE__, \ 259 "xml-blob", (level), __LINE__, 0); \ 261 if (crm_is_callsite_active(xml_cs, (level), 0)) { \ 262 log_data_element((level), __FILE__, __func__, \ 263 __LINE__, text, xml, 1, xml_log_option_formatted); \ 282 # define do_crm_log_alias(level, file, function, line, fmt, args...) do { \ 285 printf(fmt "\n" , ##args); \ 290 qb_log_from_external_source(function, file, fmt, (level), \ 310 # define crm_perror(level, fmt, args...) do { \ 315 const char *err = strerror(errno); \ 317 if ((level) <= (int) crm_log_level) { \ 318 fprintf(stderr, fmt ": %s (%d)\n" , ##args, err, errno);\ 320 do_crm_log((level), fmt ": %s (%d)" , ##args, err, errno); \ 337 # define crm_log_tag(level, tag, fmt, args...) do { \ 339 case LOG_STDOUT: case LOG_NEVER: \ 342 static struct qb_log_callsite *trace_tag_cs = NULL; \ 343 int converted_tag = g_quark_try_string(tag); \ 344 if (trace_tag_cs == NULL) { \ 345 trace_tag_cs = qb_log_callsite_get(__func__, __FILE__, \ 346 fmt, (level), __LINE__, converted_tag); \ 348 if (crm_is_callsite_active(trace_tag_cs, (level), \ 350 qb_log_from_external_source(__func__, __FILE__, fmt, \ 351 (level), __LINE__, converted_tag , ##args); \ 357 # define crm_emerg(fmt, args...) qb_log(LOG_EMERG, fmt , ##args) 358 # 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) 360 # define crm_warn(fmt, args...) qb_logt(LOG_WARNING, 0, fmt , ##args) 361 # define crm_notice(fmt, args...) qb_logt(LOG_NOTICE, 0, fmt , ##args) 362 # define crm_info(fmt, args...) qb_logt(LOG_INFO, 0, fmt , ##args) 364 # define crm_debug(fmt, args...) do_crm_log_unlikely(LOG_DEBUG, fmt , ##args) 365 # define crm_trace(fmt, args...) do_crm_log_unlikely(LOG_TRACE, fmt , ##args) 367 # define crm_log_xml_crit(xml, text) do_crm_log_xml(LOG_CRIT, text, xml) 368 # define crm_log_xml_err(xml, text) do_crm_log_xml(LOG_ERR, text, xml) 369 # define crm_log_xml_warn(xml, text) do_crm_log_xml(LOG_WARNING, text, xml) 370 # define crm_log_xml_notice(xml, text) do_crm_log_xml(LOG_NOTICE, text, xml) 371 # define crm_log_xml_info(xml, text) do_crm_log_xml(LOG_INFO, text, xml) 372 # define crm_log_xml_debug(xml, text) do_crm_log_xml(LOG_DEBUG, text, xml) 373 # define crm_log_xml_trace(xml, text) do_crm_log_xml(LOG_TRACE, text, xml) 375 # define crm_log_xml_explicit(xml, text) do { \ 376 static struct qb_log_callsite *digest_cs = NULL; \ 377 digest_cs = qb_log_callsite_get( \ 378 __func__, __FILE__, text, LOG_TRACE, __LINE__, \ 380 if (digest_cs && digest_cs->targets) { \ 381 do_crm_log_xml(LOG_TRACE, text, xml); \ 385 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1) void crm_enable_stderr(int enable)
gboolean crm_log_init(const char *entity, uint8_t level, gboolean daemon, gboolean to_stderr, int argc, char **argv, gboolean quiet)
void log_data_element(int log_level, const char *file, const char *function, int line, const char *prefix, const xmlNode *data, int depth, gboolean formatted)
unsigned int crm_trace_nonlog
Deprecated Pacemaker logging API.
void crm_bump_log_level(int argc, char **argv)
Make logging more verbose.
void crm_log_deinit(void)
gboolean crm_config_error
int daemon(int nochdir, int noclose)
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.
gboolean crm_config_warning
void crm_update_callsites(void)