 |
pacemaker
2.0.4-2deceaa3ae
Scalable High-Availability cluster resource manager
|
Go to the documentation of this file.
20 #ifndef CRM_LOGGING__H
21 # define CRM_LOGGING__H
25 # include <qb/qblog.h>
26 # include <libxml/tree.h>
36 # define LOG_TRACE (LOG_DEBUG+1)
41 # define LOG_STDOUT 254
46 # define LOG_NEVER 255
52 # define crm_extended_logging(t, e) qb_log_ctl((t), QB_LOG_CONF_EXTENDED, (e))
61 crm_extended_logging(
int t,
int e)
100 gboolean to_stderr,
int argc,
char **argv, gboolean quiet);
103 void crm_log_output_fn(
const char *file,
const char *
function,
int line,
int level,
104 const char *prefix,
const char *output);
107 # define crm_log_output(level, prefix, output) crm_log_output_fn(__FILE__, __FUNCTION__, __LINE__, level, prefix, output)
118 const char *prefix, xmlNode *
data,
int depth, gboolean formatted);
130 #if defined(__clang__)
131 # define CRM_TRACE_INIT_DATA(name)
134 # define CRM_TRACE_INIT_DATA(name) QB_LOG_INIT_DATA(name)
150 # define do_crm_log(level, fmt, args...) do { \
153 printf(fmt "\n" , ##args); \
158 qb_log_from_external_source(__func__, __FILE__, fmt, \
159 (level), __LINE__, 0 , ##args); \
174 # define do_crm_log_unlikely(level, fmt, args...) do { \
176 case LOG_STDOUT: case LOG_NEVER: \
179 static struct qb_log_callsite *trace_cs = NULL; \
180 if (trace_cs == NULL) { \
181 trace_cs = qb_log_callsite_get(__func__, __FILE__, fmt, \
182 (level), __LINE__, 0); \
184 if (crm_is_callsite_active(trace_cs, (level), 0)) { \
185 qb_log_from_external_source(__func__, __FILE__, fmt, \
186 (level), __LINE__, 0 , ##args); \
207 # define pcmk__log_else(level, else_action) do { \
208 static struct qb_log_callsite *trace_cs = NULL; \
210 if (trace_cs == NULL) { \
211 trace_cs = qb_log_callsite_get(__func__, __FILE__, "log_else", \
212 level, __LINE__, 0); \
214 if (!crm_is_callsite_active(trace_cs, level, 0)) { \
219 # define CRM_LOG_ASSERT(expr) do { \
220 if(__unlikely((expr) == FALSE)) { \
221 static struct qb_log_callsite *core_cs = NULL; \
222 if(core_cs == NULL) { \
223 core_cs = qb_log_callsite_get(__func__, __FILE__, "log-assert", LOG_TRACE, __LINE__, 0); \
225 crm_abort(__FILE__, __FUNCTION__, __LINE__, #expr, \
226 core_cs?core_cs->targets:FALSE, TRUE); \
233 # define CRM_CHECK(expr, failure_action) do { \
234 if(__unlikely((expr) == FALSE)) { \
235 static struct qb_log_callsite *core_cs = NULL; \
236 if(core_cs == NULL) { \
237 core_cs = qb_log_callsite_get(__func__, __FILE__, "check-assert", LOG_TRACE, __LINE__, 0); \
239 crm_abort(__FILE__, __FUNCTION__, __LINE__, #expr, \
240 core_cs?core_cs->targets:FALSE, TRUE); \
255 # define do_crm_log_xml(level, text, xml) do { \
257 case LOG_STDOUT: case LOG_NEVER: \
260 static struct qb_log_callsite *xml_cs = NULL; \
261 if (xml_cs == NULL) { \
262 xml_cs = qb_log_callsite_get(__func__, __FILE__, \
263 "xml-blob", (level), __LINE__, 0); \
265 if (crm_is_callsite_active(xml_cs, (level), 0)) { \
266 log_data_element((level), __FILE__, __FUNCTION__, \
267 __LINE__, text, xml, 1, xml_log_option_formatted); \
286 # define do_crm_log_alias(level, file, function, line, fmt, args...) do { \
289 printf(fmt "\n" , ##args); \
294 qb_log_from_external_source(function, file, fmt, (level), \
314 # define crm_perror(level, fmt, args...) do { \
319 const char *err = strerror(errno); \
321 if ((level) <= (int) crm_log_level) { \
322 fprintf(stderr, fmt ": %s (%d)\n" , ##args, err, errno);\
324 do_crm_log((level), fmt ": %s (%d)" , ##args, err, errno); \
341 # define crm_log_tag(level, tag, fmt, args...) do { \
343 case LOG_STDOUT: case LOG_NEVER: \
346 static struct qb_log_callsite *trace_tag_cs = NULL; \
347 int converted_tag = g_quark_try_string(tag); \
348 if (trace_tag_cs == NULL) { \
349 trace_tag_cs = qb_log_callsite_get(__func__, __FILE__, \
350 fmt, (level), __LINE__, converted_tag); \
352 if (crm_is_callsite_active(trace_tag_cs, (level), \
354 qb_log_from_external_source(__func__, __FILE__, fmt, \
355 (level), __LINE__, converted_tag , ##args); \
361 # define crm_emerg(fmt, args...) qb_log(LOG_EMERG, fmt , ##args)
362 # define crm_crit(fmt, args...) qb_logt(LOG_CRIT, 0, fmt , ##args)
363 # define crm_err(fmt, args...) qb_logt(LOG_ERR, 0, fmt , ##args)
364 # 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)
366 # define crm_info(fmt, args...) qb_logt(LOG_INFO, 0, fmt , ##args)
368 # define crm_debug(fmt, args...) do_crm_log_unlikely(LOG_DEBUG, fmt , ##args)
369 # define crm_trace(fmt, args...) do_crm_log_unlikely(LOG_TRACE, fmt , ##args)
371 # define crm_log_xml_crit(xml, text) do_crm_log_xml(LOG_CRIT, text, xml)
372 # define crm_log_xml_err(xml, text) do_crm_log_xml(LOG_ERR, text, xml)
373 # define crm_log_xml_warn(xml, text) do_crm_log_xml(LOG_WARNING, text, xml)
374 # define crm_log_xml_notice(xml, text) do_crm_log_xml(LOG_NOTICE, text, xml)
375 # define crm_log_xml_info(xml, text) do_crm_log_xml(LOG_INFO, text, xml)
376 # define crm_log_xml_debug(xml, text) do_crm_log_xml(LOG_DEBUG, text, xml)
377 # define crm_log_xml_trace(xml, text) do_crm_log_xml(LOG_TRACE, text, xml)
379 # define crm_log_xml_explicit(xml, text) do { \
380 static struct qb_log_callsite *digest_cs = NULL; \
381 digest_cs = qb_log_callsite_get( \
382 __func__, __FILE__, text, LOG_TRACE, __LINE__, \
384 if (digest_cs && digest_cs->targets) { \
385 do_crm_log_xml(LOG_TRACE, text, xml); \
389 # define crm_str(x) (const char*)(x?x:"<null>")
391 #ifndef PCMK__NO_COMPAT
408 # define do_crm_log_always(level, fmt, args...) do { \
410 case LOG_STDOUT: case LOG_NEVER: \
413 qb_log((level), fmt , ##args); \
418 #endif // PCMK__NO_COMPAT
gboolean crm_add_logfile(const char *filename)
void crm_write_blackbox(int nsig, struct qb_log_callsite *callsite)
@ xml_log_option_formatted
gboolean crm_is_callsite_active(struct qb_log_callsite *cs, uint8_t level, uint32_t tags)
@ xml_log_option_diff_plus
gboolean crm_config_error
void crm_update_callsites(void)
void crm_bump_log_level(int argc, char **argv)
unsigned int set_crm_log_level(unsigned int level)
unsigned int crm_trace_nonlog
void crm_log_preinit(const char *entity, 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_log_init(const char *entity, uint8_t level, gboolean daemon, gboolean to_stderr, int argc, char **argv, gboolean quiet)
unsigned int crm_log_level
unsigned int get_crm_log_level(void)
void crm_enable_stderr(int enable)
void crm_log_deinit(void)
void log_data_element(int log_level, const char *file, const char *function, int line, const char *prefix, xmlNode *data, int depth, gboolean formatted)
void crm_log_args(int argc, char **argv)
gboolean crm_log_cli_init(const char *entity)
@ xml_log_option_full_fledged
int daemon(int nochdir, int noclose)
@ xml_log_option_filtered
@ xml_log_option_dirty_add
void crm_enable_blackbox(int nsig)
gboolean crm_config_warning
@ xml_log_option_children
void crm_disable_blackbox(int nsig)
@ xml_log_option_diff_short
@ xml_log_option_diff_minus
@ xml_log_option_diff_all