summaryrefslogtreecommitdiffstats
path: root/include/crm/common/logging.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/crm/common/logging.h')
-rw-r--r--include/crm/common/logging.h125
1 files changed, 71 insertions, 54 deletions
diff --git a/include/crm/common/logging.h b/include/crm/common/logging.h
index eea4cec..abc2fe8 100644
--- a/include/crm/common/logging.h
+++ b/include/crm/common/logging.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2004-2023 the Pacemaker project contributors
+ * Copyright 2004-2024 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
@@ -8,13 +8,13 @@
*/
#ifndef PCMK__CRM_COMMON_LOGGING__H
-# define PCMK__CRM_COMMON_LOGGING__H
+#define PCMK__CRM_COMMON_LOGGING__H
-# include <stdio.h>
-# include <stdint.h> // uint8_t, uint32_t
-# include <glib.h>
-# include <qb/qblog.h>
-# include <libxml/tree.h>
+#include <stdio.h>
+#include <stdint.h> // uint8_t, uint32_t
+#include <glib.h>
+#include <qb/qblog.h>
+#include <libxml/tree.h>
#ifdef __cplusplus
extern "C" {
@@ -34,26 +34,26 @@ extern "C" {
*/
// Define something even less desired than debug
-# ifndef LOG_TRACE
-# define LOG_TRACE (LOG_DEBUG+1)
-# endif
+#ifndef LOG_TRACE
+#define LOG_TRACE (LOG_DEBUG+1)
+#endif
// Print message to stdout instead of logging it
-# ifndef LOG_STDOUT
-# define LOG_STDOUT 254
-# endif
+#ifndef LOG_STDOUT
+#define LOG_STDOUT 254
+#endif
// Don't send message anywhere
-# ifndef LOG_NEVER
-# define LOG_NEVER 255
-# endif
+#ifndef LOG_NEVER
+#define LOG_NEVER 255
+#endif
/* "Extended information" logging support */
#ifdef QB_XS
-# define CRM_XS QB_XS
-# define crm_extended_logging(t, e) qb_log_ctl((t), QB_LOG_CONF_EXTENDED, (e))
+#define CRM_XS QB_XS
+#define crm_extended_logging(t, e) qb_log_ctl((t), QB_LOG_CONF_EXTENDED, (e))
#else
-# define CRM_XS "|"
+#define CRM_XS "|"
/* A caller might want to check the return value, so we can't define this as a
* no-op, and we can't simply define it to be 0 because gcc will then complain
@@ -66,7 +66,12 @@ crm_extended_logging(int t, int e)
}
#endif
+// @COMPAT Make internal when we can break API backward compatibility
+//! \deprecated Do not use
extern unsigned int crm_log_level;
+
+// @COMPAT Make internal when we can break API backward compatibility
+//! \deprecated Do not use
extern unsigned int crm_trace_nonlog;
/*! \deprecated Pacemaker library functions set this when a configuration
@@ -116,6 +121,7 @@ void crm_enable_stderr(int enable);
gboolean crm_is_callsite_active(struct qb_log_callsite *cs, uint8_t level, uint32_t tags);
+// NOTE: sbd (as of at least 1.5.2) uses this
/* returns the old value */
unsigned int set_crm_log_level(unsigned int level);
@@ -131,10 +137,10 @@ void pcmk_log_xml_as(const char *file, const char *function, uint32_t line,
* https://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html#Variadic-Macros
*/
#if defined(__clang__)
-# define CRM_TRACE_INIT_DATA(name)
-# else
-# include <assert.h> // required by QB_LOG_INIT_DATA() macro
-# define CRM_TRACE_INIT_DATA(name) QB_LOG_INIT_DATA(name)
+#define CRM_TRACE_INIT_DATA(name)
+#else
+#include <assert.h> // required by QB_LOG_INIT_DATA() macro
+#define CRM_TRACE_INIT_DATA(name) QB_LOG_INIT_DATA(name)
#endif
/*!
@@ -172,7 +178,7 @@ pcmk__clip_log_level(int level)
* \param[in] fmt printf-style format string literal for message
* \param[in] args Any arguments needed by format string
*/
-# define do_crm_log(level, fmt, args...) do { \
+#define do_crm_log(level, fmt, args...) do { \
uint8_t _level = pcmk__clip_log_level(level); \
\
switch (_level) { \
@@ -197,7 +203,7 @@ pcmk__clip_log_level(int level)
*
* \note This does nothing when level is \p LOG_STDOUT.
*/
-# define do_crm_log_unlikely(level, fmt, args...) do { \
+#define do_crm_log_unlikely(level, fmt, args...) do { \
uint8_t _level = pcmk__clip_log_level(level); \
\
switch (_level) { \
@@ -219,7 +225,7 @@ pcmk__clip_log_level(int level)
} \
} while (0)
-# define CRM_LOG_ASSERT(expr) do { \
+#define CRM_LOG_ASSERT(expr) do { \
if (!(expr)) { \
static struct qb_log_callsite *core_cs = NULL; \
if(core_cs == NULL) { \
@@ -232,10 +238,11 @@ pcmk__clip_log_level(int level)
} \
} while(0)
+// NOTE: sbd (as of at least 1.5.2) uses this
/* 'failure_action' MUST NOT be 'continue' as it will apply to the
* macro's do-while loop
*/
-# define CRM_CHECK(expr, failure_action) do { \
+#define CRM_CHECK(expr, failure_action) do { \
if (!(expr)) { \
static struct qb_log_callsite *core_cs = NULL; \
if (core_cs == NULL) { \
@@ -243,10 +250,10 @@ pcmk__clip_log_level(int level)
"check-assert", \
LOG_TRACE, __LINE__, 0); \
} \
- crm_abort(__FILE__, __func__, __LINE__, #expr, \
- (core_cs? core_cs->targets: FALSE), TRUE); \
- failure_action; \
- } \
+ crm_abort(__FILE__, __func__, __LINE__, #expr, \
+ (core_cs? core_cs->targets: FALSE), TRUE); \
+ failure_action; \
+ } \
} while(0)
/*!
@@ -258,7 +265,7 @@ pcmk__clip_log_level(int level)
*
* \note This does nothing when \p level is \p LOG_STDOUT.
*/
-# define do_crm_log_xml(level, text, xml) do { \
+#define do_crm_log_xml(level, text, xml) do { \
uint8_t _level = pcmk__clip_log_level(level); \
static struct qb_log_callsite *xml_cs = NULL; \
\
@@ -290,7 +297,7 @@ pcmk__clip_log_level(int level)
* \param[in] fmt printf-style format string literal for message
* \param[in] args Any arguments needed by format string
*/
-# define do_crm_log_alias(level, file, function, line, fmt, args...) do { \
+#define do_crm_log_alias(level, file, function, line, fmt, args...) do { \
uint8_t _level = pcmk__clip_log_level(level); \
\
switch (_level) { \
@@ -306,6 +313,7 @@ pcmk__clip_log_level(int level)
} \
} while (0)
+// NOTE: sbd (as of at least 1.5.2) uses this
/*!
* \brief Send a system error message to both the log and stderr
*
@@ -320,7 +328,7 @@ pcmk__clip_log_level(int level)
* 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.
*/
-# define crm_perror(level, fmt, args...) do { \
+#define crm_perror(level, fmt, args...) do { \
uint8_t _level = pcmk__clip_log_level(level); \
\
switch (_level) { \
@@ -351,7 +359,7 @@ pcmk__clip_log_level(int level)
*
* \note This does nothing when level is LOG_STDOUT.
*/
-# define crm_log_tag(level, tag, fmt, args...) do { \
+#define crm_log_tag(level, tag, fmt, args...) do { \
uint8_t _level = pcmk__clip_log_level(level); \
\
switch (_level) { \
@@ -376,25 +384,34 @@ pcmk__clip_log_level(int level)
} \
} while (0)
-# define crm_emerg(fmt, args...) qb_log(LOG_EMERG, 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) do { \
+#define crm_emerg(fmt, args...) qb_log(LOG_EMERG, fmt , ##args)
+#define crm_crit(fmt, args...) qb_logt(LOG_CRIT, 0, fmt , ##args)
+
+// NOTE: sbd (as of at least 1.5.2) uses this
+#define crm_err(fmt, args...) qb_logt(LOG_ERR, 0, fmt , ##args)
+
+// NOTE: sbd (as of at least 1.5.2) uses this
+#define crm_warn(fmt, args...) qb_logt(LOG_WARNING, 0, fmt , ##args)
+
+// NOTE: sbd (as of at least 1.5.2) uses this
+#define crm_notice(fmt, args...) qb_logt(LOG_NOTICE, 0, fmt , ##args)
+
+#define crm_info(fmt, args...) qb_logt(LOG_INFO, 0, fmt , ##args)
+ //
+// NOTE: sbd (as of at least 1.5.2) uses this
+#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) do { \
static struct qb_log_callsite *digest_cs = NULL; \
digest_cs = qb_log_callsite_get( \
__func__, __FILE__, text, LOG_TRACE, __LINE__, \