pacemaker  2.1.8-3980678f03
Scalable High-Availability cluster resource manager
Macros | Typedefs | Functions | Variables
logging.c File Reference
#include <crm_internal.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <sys/utsname.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#include <ctype.h>
#include <pwd.h>
#include <grp.h>
#include <time.h>
#include <libgen.h>
#include <signal.h>
#include <bzlib.h>
#include <qb/qbdefs.h>
#include <crm/crm.h>
#include <crm/common/mainloop.h>
#include <crm/common/logging_compat.h>
Include dependency graph for logging.c:

Go to the source code of this file.

Macros

#define TIMESTAMP_FORMAT_SPEC   "%%t"
 
#define NAME_MAX   256
 
#define FMT_MAX   256
 
#define DEFAULT_LOG_FILE   CRM_LOG_DIR "/pacemaker.log"
 

Typedefs

typedef time_t log_time_t
 

Functions

void crm_log_deinit (void)
 
int pcmk__add_logfile (const char *filename)
 Add a file to be used as a Pacemaker detail log. More...
 
void pcmk__add_logfiles (gchar **log_files, pcmk__output_t *out)
 Add multiple additional log files. More...
 
void crm_enable_blackbox (int nsig)
 
void crm_disable_blackbox (int nsig)
 
void crm_write_blackbox (int nsig, const struct qb_log_callsite *cs)
 
gboolean crm_is_callsite_active (struct qb_log_callsite *cs, uint8_t level, uint32_t tags)
 
void crm_update_callsites (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. More...
 
gboolean crm_log_init (const char *entity, uint8_t level, gboolean daemon, gboolean to_stderr, int argc, char **argv, gboolean quiet)
 
unsigned int set_crm_log_level (unsigned int level)
 
void crm_enable_stderr (int enable)
 
void crm_bump_log_level (int argc, char **argv)
 Make logging more verbose. More...
 
unsigned int get_crm_log_level (void)
 
void crm_log_args (int argc, char **argv)
 Log the command line (once) More...
 
void crm_log_output_fn (const char *file, const char *function, int line, int level, const char *prefix, const char *output)
 
void pcmk__cli_init_logging (const char *name, unsigned int verbosity)
 
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. More...
 
void pcmk__log_xml_changes_as (const char *file, const char *function, uint32_t line, uint32_t tags, uint8_t level, const xmlNode *xml)
 
void pcmk__log_xml_patchset_as (const char *file, const char *function, uint32_t line, uint32_t tags, uint8_t level, const xmlNode *patchset)
 
void pcmk__free_common_logger (void)
 
gboolean crm_log_cli_init (const char *entity)
 
gboolean crm_add_logfile (const char *filename)
 
void pcmk_log_xml_impl (uint8_t level, const char *text, const xmlNode *xml)
 
void pcmk__set_config_error_handler (pcmk__config_error_func error_handler, void *error_context)
 
void pcmk__set_config_warning_handler (pcmk__config_warning_func warning_handler, void *warning_context)
 

Variables

unsigned int crm_log_level = LOG_INFO
 
unsigned int crm_trace_nonlog = 0
 
bool pcmk__is_daemon = false
 
char * pcmk__our_nodename = NULL
 Node name of the local node. More...
 
pcmk__config_error_func pcmk__config_error_handler = NULL
 
pcmk__config_warning_func pcmk__config_warning_handler = NULL
 
void * pcmk__config_error_context = NULL
 
void * pcmk__config_warning_context = NULL
 

Macro Definition Documentation

◆ DEFAULT_LOG_FILE

#define DEFAULT_LOG_FILE   CRM_LOG_DIR "/pacemaker.log"

Definition at line 190 of file logging.c.

◆ FMT_MAX

#define FMT_MAX   256

Definition at line 138 of file logging.c.

◆ NAME_MAX

#define NAME_MAX   256

Definition at line 109 of file logging.c.

◆ TIMESTAMP_FORMAT_SPEC

#define TIMESTAMP_FORMAT_SPEC   "%%t"

Definition at line 41 of file logging.c.

Typedef Documentation

◆ log_time_t

typedef time_t log_time_t

Definition at line 42 of file logging.c.

Function Documentation

◆ crm_add_logfile()

gboolean crm_add_logfile ( const char *  filename)
Deprecated:
Do not use Pacemaker for general-purpose logging

Definition at line 1273 of file logging.c.

◆ 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]argcIgnored
[in]argvIgnored

Definition at line 1063 of file logging.c.

◆ crm_disable_blackbox()

void crm_disable_blackbox ( int  nsig)

Definition at line 489 of file logging.c.

◆ crm_enable_blackbox()

void crm_enable_blackbox ( int  nsig)

Definition at line 483 of file logging.c.

◆ crm_enable_stderr()

void crm_enable_stderr ( int  enable)

Definition at line 1042 of file logging.c.

◆ crm_is_callsite_active()

gboolean crm_is_callsite_active ( struct qb_log_callsite *  cs,
uint8_t  level,
uint32_t  tags 
)

Definition at line 680 of file logging.c.

◆ crm_log_args()

void crm_log_args ( int  argc,
char **  argv 
)

Log the command line (once)

Parameters
[in]Numberof values in argv
[in]Command-linearguments (including command name)
Note
This function will only log once, even if called with different arguments.

Definition at line 1089 of file logging.c.

◆ crm_log_cli_init()

gboolean crm_log_cli_init ( const char *  entity)
Deprecated:
Do not use Pacemaker for general-purpose logging

Definition at line 1266 of file logging.c.

◆ crm_log_deinit()

void crm_log_deinit ( void  )

Definition at line 131 of file logging.c.

◆ crm_log_init()

gboolean crm_log_init ( const char *  entity,
uint8_t  level,
gboolean  daemon,
gboolean  to_stderr,
int  argc,
char **  argv,
gboolean  quiet 
)

Definition at line 894 of file logging.c.

◆ 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 
)

Definition at line 1104 of file logging.c.

◆ 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]entityIf not NULL, will be used as the identity for logging purposes
[in]argcThe number of command line parameters
[in]argvThe command line parameter values

Definition at line 809 of file logging.c.

◆ crm_update_callsites()

void crm_update_callsites ( void  )

Definition at line 709 of file logging.c.

◆ crm_write_blackbox()

void crm_write_blackbox ( int  nsig,
const struct qb_log_callsite *  cs 
)

Definition at line 505 of file logging.c.

◆ get_crm_log_level()

unsigned int get_crm_log_level ( void  )

Definition at line 1074 of file logging.c.

◆ pcmk__add_logfile()

int pcmk__add_logfile ( const char *  filename)

Add a file to be used as a Pacemaker detail log.

Parameters
[in]filenameName of log file to use
Returns
Standard Pacemaker return code

Definition at line 317 of file logging.c.

◆ pcmk__add_logfiles()

void pcmk__add_logfiles ( gchar **  log_files,
pcmk__output_t out 
)

Add multiple additional log files.

Parameters
[in]log_filesArray of log files to add
[in]outOutput object to use for error reporting
Returns
Standard Pacemaker return code

Definition at line 401 of file logging.c.

◆ pcmk__cli_init_logging()

void pcmk__cli_init_logging ( const char *  name,
unsigned int  verbosity 
)

Definition at line 1135 of file logging.c.

◆ pcmk__free_common_logger()

void pcmk__free_common_logger ( void  )

Definition at line 1251 of file logging.c.

◆ pcmk__log_xml_changes_as()

void pcmk__log_xml_changes_as ( const char *  file,
const char *  function,
uint32_t  line,
uint32_t  tags,
uint8_t  level,
const xmlNode *  xml 
)

Definition at line 1198 of file logging.c.

◆ pcmk__log_xml_patchset_as()

void pcmk__log_xml_patchset_as ( const char *  file,
const char *  function,
uint32_t  line,
uint32_t  tags,
uint8_t  level,
const xmlNode *  patchset 
)

Definition at line 1229 of file logging.c.

◆ pcmk__set_config_error_handler()

void pcmk__set_config_error_handler ( pcmk__config_error_func  error_handler,
void *  error_context 
)

Definition at line 1287 of file logging.c.

◆ pcmk__set_config_warning_handler()

void pcmk__set_config_warning_handler ( pcmk__config_warning_func  warning_handler,
void *  warning_context 
)

Definition at line 1293 of file logging.c.

◆ 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]fileFile name to use for log filtering
[in]functionFunction name to use for log filtering
[in]lineLine number to use for log filtering
[in]tagsLogging tags to use for log filtering
[in]levelPriority at which to log the messages
[in]textPrefix for each line
[in]xmlXML 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 1161 of file logging.c.

◆ pcmk_log_xml_impl()

void pcmk_log_xml_impl ( uint8_t  level,
const char *  text,
const xmlNode *  xml 
)
Deprecated:
Do not use Pacemaker for general-purpose logging

Definition at line 1279 of file logging.c.

◆ set_crm_log_level()

unsigned int set_crm_log_level ( unsigned int  level)

Definition at line 1028 of file logging.c.

Variable Documentation

◆ crm_log_level

unsigned int crm_log_level = LOG_INFO
Deprecated:
Do not use

Definition at line 45 of file logging.c.

◆ crm_trace_nonlog

unsigned int crm_trace_nonlog = 0
Deprecated:
Do not use

Definition at line 46 of file logging.c.

◆ pcmk__config_error_context

void* pcmk__config_error_context = NULL

Definition at line 56 of file logging.c.

◆ pcmk__config_error_handler

pcmk__config_error_func pcmk__config_error_handler = NULL

Definition at line 54 of file logging.c.

◆ pcmk__config_warning_context

void* pcmk__config_warning_context = NULL

Definition at line 57 of file logging.c.

◆ pcmk__config_warning_handler

pcmk__config_warning_func pcmk__config_warning_handler = NULL

Definition at line 55 of file logging.c.

◆ pcmk__is_daemon

bool pcmk__is_daemon = false

Definition at line 47 of file logging.c.

◆ pcmk__our_nodename

char* pcmk__our_nodename = NULL

Node name of the local node.

Definition at line 48 of file logging.c.