root/include/crm/common/logging_internal.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * Copyright 2015-2023 the Pacemaker project contributors
   3  *
   4  * The version control history for this file may have further details.
   5  *
   6  * This source code is licensed under the GNU General Public License version 2
   7  * or later (GPLv2+) WITHOUT ANY WARRANTY.
   8  */
   9 
  10 #ifdef __cplusplus
  11 extern "C" {
  12 #endif
  13 
  14 #ifndef PCMK__LOGGING_INTERNAL_H
  15 #  define PCMK__LOGGING_INTERNAL_H
  16 
  17 #  include <glib.h>
  18 
  19 #  include <crm/common/logging.h>
  20 #  include <crm/common/output_internal.h>
  21 
  22 /*!
  23  * \internal
  24  * \brief Log a configuration error
  25  *
  26  * \param[in] fmt   printf(3)-style format string
  27  * \param[in] ...   Arguments for format string
  28  */
  29 #  define pcmk__config_err(fmt...) do {     \
  30         crm_config_error = TRUE;            \
  31         crm_err(fmt);                       \
  32     } while (0)
  33 
  34 /*!
  35  * \internal
  36  * \brief Log a configuration warning
  37  *
  38  * \param[in] fmt   printf(3)-style format string
  39  * \param[in] ...   Arguments for format string
  40  */
  41 #  define pcmk__config_warn(fmt...) do {    \
  42         crm_config_warning = TRUE;          \
  43         crm_warn(fmt);                      \
  44     } while (0)
  45 
  46 /*!
  47  * \internal
  48  * \brief Execute code depending on whether trace logging is enabled
  49  *
  50  * This is similar to \p do_crm_log_unlikely() except instead of logging, it
  51  * selects one of two code blocks to execute.
  52  *
  53  * \param[in] if_action    Code block to execute if trace logging is enabled
  54  * \param[in] else_action  Code block to execute if trace logging is not enabled
  55  *
  56  * \note Neither \p if_action nor \p else_action can contain a \p break or
  57  *       \p continue statement.
  58  */
  59 #  define pcmk__if_tracing(if_action, else_action) do {                 \
  60         static struct qb_log_callsite *trace_cs = NULL;                 \
  61                                                                         \
  62         if (trace_cs == NULL) {                                         \
  63             trace_cs = qb_log_callsite_get(__func__, __FILE__,          \
  64                                            "if_tracing", LOG_TRACE,     \
  65                                            __LINE__, crm_trace_nonlog); \
  66         }                                                               \
  67         if (crm_is_callsite_active(trace_cs, LOG_TRACE,                 \
  68                                    crm_trace_nonlog)) {                 \
  69             if_action;                                                  \
  70         } else {                                                        \
  71             else_action;                                                \
  72         }                                                               \
  73     } while (0)
  74 
  75 /*!
  76  * \internal
  77  * \brief Initialize logging for command line tools
  78  *
  79  * \param[in] name      The name of the program
  80  * \param[in] verbosity How verbose to be in logging
  81  *
  82  * \note \p verbosity is not the same as the logging level (LOG_ERR, etc.).
  83  */
  84 void pcmk__cli_init_logging(const char *name, unsigned int verbosity);
  85 
  86 int pcmk__add_logfile(const char *filename);
  87 void pcmk__add_logfiles(gchar **log_files, pcmk__output_t *out);
  88 
  89 void pcmk__free_common_logger(void);
  90 
  91 #ifdef __cplusplus
  92 }
  93 #endif
  94 
  95 #endif

/* [previous][next][first][last][top][bottom][index][help] */