Wrappers for and extensions to libqb logging.
More...
#include <stdio.h>
#include <stdint.h>
#include <glib.h>
#include <qb/qblog.h>
#include <libxml/tree.h>
#include <assert.h>
#include <crm/common/logging_compat.h>
Go to the source code of this file.
|
#define | LOG_TRACE (LOG_DEBUG+1) |
|
#define | LOG_STDOUT 254 |
|
#define | LOG_NEVER 255 |
|
#define | crm_log_output(level, prefix, output) |
|
#define | CRM_TRACE_INIT_DATA(name) |
|
#define | do_crm_log(level, fmt, args...) |
| Log a message.
|
|
#define | do_crm_log_unlikely(level, fmt, args...) |
| Log a message that is likely to be filtered out.
|
|
#define | CRM_LOG_ASSERT(expr) |
|
#define | CRM_CHECK(expr, failure_action) |
|
#define | do_crm_log_xml(level, text, xml) |
| Log XML line-by-line in a formatted fashion.
|
|
#define | do_crm_log_alias(level, file, function, line, fmt, args...) |
| Log a message as if it came from a different code location.
|
|
#define | crm_perror(level, fmt, args...) |
| Send a system error message to both the log and stderr.
|
|
#define | crm_log_tag(level, tag, fmt, args...) |
| Log a message with a tag (for use with PCMK_trace_tags)
|
|
#define | crm_emerg(fmt, args...) |
|
#define | crm_crit(fmt, args...) |
|
#define | crm_err(fmt, args...) |
|
#define | crm_warn(fmt, args...) |
|
#define | crm_notice(fmt, args...) |
|
#define | crm_info(fmt, args...) |
|
#define | crm_debug(fmt, args...) |
|
#define | crm_trace(fmt, args...) |
|
#define | crm_log_xml_crit(xml, text) |
|
#define | crm_log_xml_err(xml, text) |
|
#define | crm_log_xml_warn(xml, text) |
|
#define | crm_log_xml_notice(xml, text) |
|
#define | crm_log_xml_info(xml, text) |
|
#define | crm_log_xml_debug(xml, text) |
|
#define | crm_log_xml_trace(xml, text) |
|
#define | crm_log_xml_explicit(xml, text) |
|
|
void | crm_enable_blackbox (int nsig) |
|
void | crm_disable_blackbox (int nsig) |
|
void | crm_write_blackbox (int nsig, const struct qb_log_callsite *callsite) |
|
void | crm_update_callsites (void) |
|
void | crm_log_deinit (void) |
|
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_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) |
| Log the command line (once)
|
|
void | crm_log_output_fn (const char *file, const char *function, int line, int level, const char *prefix, const char *output) |
|
void | crm_bump_log_level (int argc, char **argv) |
| Make logging more verbose.
|
|
void | crm_enable_stderr (int enable) |
|
gboolean | crm_is_callsite_active (struct qb_log_callsite *cs, uint8_t level, uint32_t tags) |
|
unsigned int | set_crm_log_level (unsigned int level) |
|
unsigned int | get_crm_log_level (void) |
|
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.
|
|
Wrappers for and extensions to libqb logging.
Definition in file logging.h.
◆ CRM_CHECK
#define CRM_CHECK |
( |
| expr, |
|
|
| failure_action ) |
Value: do { \
if (!(expr)) { \
static struct qb_log_callsite *core_cs = NULL; \
if (core_cs == NULL) { \
core_cs = qb_log_callsite_get(__func__, __FILE__, \
"check-assert", \
} \
crm_abort(__FILE__, __func__, __LINE__, #expr, \
(core_cs? core_cs->targets: FALSE), TRUE); \
failure_action; \
} \
} while(0)
Definition at line 213 of file logging.h.
◆ crm_crit
#define crm_crit |
( |
| fmt, |
|
|
| args... ) |
Value:qb_logt(LOG_CRIT, 0, fmt , ##args)
Definition at line 354 of file logging.h.
◆ crm_debug
#define crm_debug |
( |
| fmt, |
|
|
| args... ) |
Value:
#define do_crm_log_unlikely(level, fmt, args...)
Log a message that is likely to be filtered out.
Definition at line 368 of file logging.h.
◆ crm_emerg
#define crm_emerg |
( |
| fmt, |
|
|
| args... ) |
Value:qb_log(LOG_EMERG, fmt , ##args)
Definition at line 353 of file logging.h.
◆ crm_err
#define crm_err |
( |
| fmt, |
|
|
| args... ) |
Value:qb_logt(LOG_ERR, 0, fmt , ##args)
Definition at line 357 of file logging.h.
◆ crm_info
#define crm_info |
( |
| fmt, |
|
|
| args... ) |
Value:qb_logt(LOG_INFO, 0, fmt , ##args)
Definition at line 365 of file logging.h.
◆ CRM_LOG_ASSERT
#define CRM_LOG_ASSERT |
( |
| expr | ) |
|
Value: do { \
if (!(expr)) { \
static struct qb_log_callsite *core_cs = NULL; \
if(core_cs == NULL) { \
core_cs = qb_log_callsite_get(__func__, __FILE__, \
__LINE__, 0); \
} \
crm_abort(__FILE__, __func__, __LINE__, #expr, \
core_cs?core_cs->targets:FALSE, TRUE); \
} \
} while(0)
Definition at line 196 of file logging.h.
◆ crm_log_output
#define crm_log_output |
( |
| level, |
|
|
| prefix, |
|
|
| output ) |
Value:
void crm_log_output_fn(const char *file, const char *function, int line, int level, const char *prefix, const char *output)
Definition at line 83 of file logging.h.
◆ crm_log_tag
#define crm_log_tag |
( |
| level, |
|
|
| tag, |
|
|
| fmt, |
|
|
| args... ) |
Value: do { \
uint8_t _level = pcmk__clip_log_level(level); \
\
switch (_level) { \
break; \
default: { \
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); \
} \
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)
Log a message with a tag (for use with PCMK_trace_tags)
- Parameters
-
[in] | level | Priority at which to log the message |
[in] | tag | String to tag message with |
[in] | fmt | printf-style format string for message |
[in] | args | Any arguments needed by format string |
- Note
- This does nothing when level is LOG_STDOUT.
Definition at line 328 of file logging.h.
◆ crm_log_xml_crit
#define crm_log_xml_crit |
( |
| xml, |
|
|
| text ) |
Value:
#define do_crm_log_xml(level, text, xml)
Log XML line-by-line in a formatted fashion.
Definition at line 372 of file logging.h.
◆ crm_log_xml_debug
#define crm_log_xml_debug |
( |
| xml, |
|
|
| text ) |
◆ crm_log_xml_err
#define crm_log_xml_err |
( |
| xml, |
|
|
| text ) |
◆ crm_log_xml_explicit
#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) { \
} \
} while(0)
unsigned int crm_trace_nonlog
Definition at line 380 of file logging.h.
◆ crm_log_xml_info
#define crm_log_xml_info |
( |
| xml, |
|
|
| text ) |
◆ crm_log_xml_notice
#define crm_log_xml_notice |
( |
| xml, |
|
|
| text ) |
◆ crm_log_xml_trace
#define crm_log_xml_trace |
( |
| xml, |
|
|
| text ) |
◆ crm_log_xml_warn
#define crm_log_xml_warn |
( |
| xml, |
|
|
| text ) |
◆ crm_notice
#define crm_notice |
( |
| fmt, |
|
|
| args... ) |
Value:qb_logt(LOG_NOTICE, 0, fmt , ##args)
Definition at line 363 of file logging.h.
◆ crm_perror
#define crm_perror |
( |
| level, |
|
|
| fmt, |
|
|
| args... ) |
Value: do { \
uint8_t _level = pcmk__clip_log_level(level); \
\
switch (_level) { \
break; \
default: { \
const char *err = strerror(errno); \
fprintf(stderr, fmt ": %s (%d)\n" , ##args, err, \
errno); \
} \
\
do_crm_log((level), fmt ": %s (%d)" , ##args, err, errno); \
} \
break; \
} \
} while (0)
unsigned int crm_log_level
Send a system error message to both the log and stderr.
- Parameters
-
[in] | level | Priority at which to log the message |
[in] | fmt | printf-style format string for message |
[in] | args | Any arguments needed by format string |
- Deprecated
- One of the other logging functions should be used with pcmk_strerror() instead.
- Note
- This is a macro, and
level
may be evaluated more than once.
-
Because crm_perror() adds the system error message and error number onto the end of fmt, that information will become extended information if QB_XS is used inside fmt and will not show up in syslog.
Definition at line 299 of file logging.h.
◆ crm_trace
#define crm_trace |
( |
| fmt, |
|
|
| args... ) |
◆ CRM_TRACE_INIT_DATA
#define CRM_TRACE_INIT_DATA |
( |
| name | ) |
|
◆ crm_warn
#define crm_warn |
( |
| fmt, |
|
|
| args... ) |
Value:qb_logt(LOG_WARNING, 0, fmt , ##args)
Definition at line 360 of file logging.h.
◆ do_crm_log
#define do_crm_log |
( |
| level, |
|
|
| fmt, |
|
|
| args... ) |
Value: do { \
uint8_t _level = pcmk__clip_log_level(level); \
\
switch (_level) { \
printf(fmt "\n" , ##args); \
break; \
break; \
default: \
qb_log_from_external_source(__func__, __FILE__, fmt, \
_level, __LINE__, 0 , ##args); \
break; \
} \
} while (0)
Log a message.
- Parameters
-
[in] | level | Priority at which to log the message |
[in] | fmt | printf-style format string literal for message |
[in] | args | Any arguments needed by format string |
Definition at line 149 of file logging.h.
◆ do_crm_log_alias
#define do_crm_log_alias |
( |
| level, |
|
|
| file, |
|
|
| function, |
|
|
| line, |
|
|
| fmt, |
|
|
| args... ) |
Value: do { \
uint8_t _level = pcmk__clip_log_level(level); \
\
switch (_level) { \
printf(fmt "\n" , ##args); \
break; \
break; \
default: \
qb_log_from_external_source(function, file, fmt, _level, \
line, 0 , ##args); \
break; \
} \
} while (0)
Log a message as if it came from a different code location.
- Parameters
-
[in] | level | Priority at which to log the message |
[in] | file | Source file name to use instead of FILE |
[in] | function | Source function name to use instead of func |
[in] | line | Source line number to use instead of line |
[in] | fmt | printf-style format string literal for message |
[in] | args | Any arguments needed by format string |
Definition at line 268 of file logging.h.
◆ do_crm_log_unlikely
#define do_crm_log_unlikely |
( |
| level, |
|
|
| fmt, |
|
|
| args... ) |
Value: do { \
uint8_t _level = pcmk__clip_log_level(level); \
\
switch (_level) { \
break; \
default: { \
static struct qb_log_callsite *trace_cs = NULL; \
if (trace_cs == NULL) { \
trace_cs = qb_log_callsite_get(__func__, __FILE__, fmt, \
_level, __LINE__, 0); \
} \
qb_log_from_external_source(__func__, __FILE__, fmt, \
_level, __LINE__, 0 , \
##args); \
} \
} \
break; \
} \
} while (0)
Log a message that is likely to be filtered out.
- Parameters
-
[in] | level | Priority at which to log the message |
[in] | fmt | printf-style format string for message |
[in] | args | Any arguments needed by format string |
- Note
- This does nothing when level is
LOG_STDOUT
.
Definition at line 174 of file logging.h.
◆ do_crm_log_xml
#define do_crm_log_xml |
( |
| level, |
|
|
| text, |
|
|
| xml ) |
Value: do { \
uint8_t _level = pcmk__clip_log_level(level); \
static struct qb_log_callsite *xml_cs = NULL; \
\
switch (_level) { \
break; \
default: \
if (xml_cs == NULL) { \
xml_cs = qb_log_callsite_get(__func__, __FILE__, \
"xml-blob", _level, \
__LINE__, 0); \
} \
pcmk_log_xml_as(__FILE__, __func__, __LINE__, 0, \
_level, text, (xml)); \
} \
break; \
} \
} while(0)
Log XML line-by-line in a formatted fashion.
- Parameters
-
[in] | level | Priority at which to log the messages |
[in] | text | Prefix for each line |
[in] | xml | XML to log |
- Note
- This does nothing when
level
is LOG_STDOUT
.
Definition at line 236 of file logging.h.
◆ LOG_NEVER
◆ LOG_STDOUT
◆ LOG_TRACE
#define LOG_TRACE (LOG_DEBUG+1) |
◆ crm_bump_log_level()
void crm_bump_log_level |
( |
int | argc, |
|
|
char ** | argv ) |
Make logging more verbose.
If logging to stderr is not already enabled when this function is called, enable it. Otherwise, increase the log level by 1.
- Parameters
-
[in] | argc | Ignored |
[in] | argv | Ignored |
Definition at line 1092 of file logging.c.
◆ crm_disable_blackbox()
void crm_disable_blackbox |
( |
int | nsig | ) |
|
◆ crm_enable_blackbox()
void crm_enable_blackbox |
( |
int | nsig | ) |
|
◆ crm_enable_stderr()
void crm_enable_stderr |
( |
int | enable | ) |
|
◆ crm_is_callsite_active()
gboolean crm_is_callsite_active |
( |
struct qb_log_callsite * | cs, |
|
|
uint8_t | level, |
|
|
uint32_t | tags ) |
◆ crm_log_args()
void crm_log_args |
( |
int | argc, |
|
|
char ** | argv ) |
Log the command line (once)
- Parameters
-
[in] | Number | of values in argv |
[in] | Command-line | arguments (including command name) |
- Note
- This function will only log once, even if called with different arguments.
Definition at line 1118 of file logging.c.
◆ crm_log_deinit()
void crm_log_deinit |
( |
void | | ) |
|
◆ crm_log_init()
gboolean crm_log_init |
( |
const char * | entity, |
|
|
uint8_t | level, |
|
|
gboolean | daemon, |
|
|
gboolean | to_stderr, |
|
|
int | argc, |
|
|
char ** | argv, |
|
|
gboolean | quiet ) |
◆ crm_log_output_fn()
void crm_log_output_fn |
( |
const char * | file, |
|
|
const char * | function, |
|
|
int | line, |
|
|
int | level, |
|
|
const char * | prefix, |
|
|
const char * | output ) |
◆ crm_log_preinit()
void crm_log_preinit |
( |
const char * | entity, |
|
|
int | argc, |
|
|
char *const * | argv ) |
Initializes the logging system and defaults to the least verbose output level.
- Parameters
-
[in] | entity | If not NULL, will be used as the identity for logging purposes |
[in] | argc | The number of command line parameters |
[in] | argv | The command line parameter values |
Definition at line 823 of file logging.c.
◆ crm_update_callsites()
void crm_update_callsites |
( |
void | | ) |
|
◆ crm_write_blackbox()
void crm_write_blackbox |
( |
int | nsig, |
|
|
const struct qb_log_callsite * | callsite ) |
◆ get_crm_log_level()
unsigned int get_crm_log_level |
( |
void | | ) |
|
◆ pcmk_log_xml_as()
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.
- Parameters
-
[in] | file | File name to use for log filtering |
[in] | function | Function name to use for log filtering |
[in] | line | Line number to use for log filtering |
[in] | tags | Logging tags to use for log filtering |
[in] | level | Priority at which to log the messages |
[in] | text | Prefix for each line |
[in] | xml | XML to log |
- Note
- This does nothing when
level
is LOG_STDOUT
.
-
Do not call this function directly. It should be called only from the
do_crm_log_xml()
macro.
Definition at line 1190 of file logging.c.
◆ set_crm_log_level()
unsigned int set_crm_log_level |
( |
unsigned int | level | ) |
|
◆ crm_log_level
unsigned int crm_log_level |
|
extern |
◆ crm_trace_nonlog
unsigned int crm_trace_nonlog |
|
extern |