logsys.h File Reference
`#include <stdarg.h>`
`#include <stdlib.h>`
`#include <syslog.h>`
`#include <pthread.h>`
`#include <limits.h>`
`#include <corosync/corotypes.h>`
`#include <qb/qbconfig.h>`
`#include <qb/qblog.h>`
Include dependency graph for logsys.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Macros

#define | LOGSYS_MODE_OUTPUT_FILE (1<<0)
#define | LOGSYS_MODE_OUTPUT_STDERR (1<<1)
#define | LOGSYS_MODE_OUTPUT_SYSLOG (1<<2)
#define | LOGSYS_MODE_FORK (1<<3)
#define | LOGSYS_MODE_THREADED (1<<4)
#define | LOGSYS_LEVEL_EMERG LOG_EMERG
#define | LOGSYS_LEVEL_ALERT LOG_ALERT
#define | LOGSYS_LEVEL_CRIT LOG_CRIT
#define | LOGSYS_LEVEL_ERROR LOG_ERR
#define | LOGSYS_LEVEL_WARNING LOG_WARNING
#define | LOGSYS_LEVEL_NOTICE LOG_NOTICE
#define | LOGSYS_LEVEL_INFO LOG_INFO
#define | LOGSYS_LEVEL_DEBUG LOG_DEBUG
#define | LOGSYS_LEVEL_TRACE LOG_TRACE
#define | LOGSYS_MAX_SUBSYS_COUNT 32
#define | LOGSYS_MAX_SUBSYS_NAMELEN 64
#define | LOGSYS_MAX_PERROR_MSG_LEN 128
#define | LOGSYS_DEBUG_OFF 0
#define | LOGSYS_DEBUG_ON 1
#define | LOGSYS_DEBUG_TRACE 2
#define | LOGSYS_DECLARE_SYSTEM(name, mode, syslog_facility, syslog_priority)
| The LOGSYS_DECLARE_SYSTEM macro.
#define | LOGSYS_DECLARE_SUBSYS(subsys)
| The LOGSYS_DECLARE_SUBSYS macro.
#define | LOGSYS_PERROR(err_num, level, fmt, args...)
| The LOGSYS_PERROR macro.
#define | log_printf(level, format, args...)
#define | ENTER qb_enter
#define | LEAVE qb_leave
#define | TRACE1(format, args...)
#define | TRACE2(format, args...)
#define | TRACE3(format, args...)
#define | TRACE4(format, args...)
#define | TRACE5(format, args...)
#define | TRACE6(format, args...)
#define | TRACE7(format, args...)
#define | TRACE8(format, args...)

## Functions

int | logsys_format_set (const char *format)
| configuration bits that can only be done for the whole system
char * | logsys_format_get (void)
| logsys_format_get
int | logsys_config_syslog_facility_set (const char *subsys, unsigned int facility)
| per system/subsystem settings.
int | logsys_config_syslog_priority_set (const char *subsys, unsigned int priority)
| logsys_config_syslog_priority_set
int | logsys_config_mode_set (const char *subsys, unsigned int mode)
| logsys_config_mode_set
unsigned int | logsys_config_mode_get (const char *subsys)
| logsys_config_mode_get
void | logsys_config_apply (void)
| logsys_config_apply
int | logsys_config_file_set (const char *subsys, const char **error_string, const char *file)
| to close a logfile, just invoke this function with a NULL file or if you want to change logfile, the old one will be closed for you.
int | logsys_config_logfile_priority_set (const char *subsys, unsigned int priority)
| logsys_config_logfile_priority_set
int | logsys_config_debug_set (const char *subsys, unsigned int value)
| enabling debug, disable message priority filtering.
int | logsys_config_debug_get (const char *subsys)
| Return the debug flag for this subsys.
int | logsys_priority_id_get (const char *name)
| logsys_priority_id_get
const char * | logsys_priority_name_get (unsigned int priority)
| logsys_priority_name_get
int | _logsys_system_setup (const char *mainsystem, unsigned int mode, int syslog_facility, int syslog_priority)
| _logsys_system_setup
void | logsys_system_fini (void)
| logsys_system_fini
int | _logsys_config_subsys_get (const char *subsys)
| _logsys_config_subsys_get
int | _logsys_subsys_create (const char *subsys, const char *filename)
| _logsys_subsys_create
int | logsys_thread_start (void)
| logsys_thread_start
void | logsys_blackbox_set (int enable)
void | logsys_blackbox_prefork (void)
void | logsys_blackbox_postfork (void)
cs_error_t | logsys_reopen_log_files (void)

## Macro Definition Documentation

## ENTER

#define ENTER qb_enter

Definition at line 333 of file logsys.h.

Referenced by sync_abort(), sync_save_transitional(), sync_start(), and votequorum_init().

## LEAVE

#define LEAVE qb_leave

Definition at line 334 of file logsys.h.

Referenced by votequorum_init().

## log_printf

#define log_printf | ( |  | level,
|  |  | format,
|  |  | args... )

Value:
qb_log(level, format, ##args)

Definition at line 332 of file logsys.h.

Referenced by _corosync_exit_error(), corosync_service_defaults_link_and_init(), corosync_service_link_and_init(), cs_ipcs_service_init(), main(), stats_map_track_add(), stats_map_track_delete(), sync_init(), totemconfig_configure_new_params(), totemip_parse(), and totemknet_configure_log_level().

## LOGSYS_DEBUG_OFF

#define LOGSYS_DEBUG_OFF 0

Definition at line 92 of file logsys.h.

Referenced by _logsys_system_setup(), and totemknet_configure_log_level().

## LOGSYS_DEBUG_ON

#define LOGSYS_DEBUG_ON 1

Definition at line 93 of file logsys.h.

Referenced by totemknet_configure_log_level().

## LOGSYS_DEBUG_TRACE

#define LOGSYS_DEBUG_TRACE 2

Definition at line 94 of file logsys.h.

Referenced by totemknet_configure_log_level().

## LOGSYS_DECLARE_SUBSYS

#define LOGSYS_DECLARE_SUBSYS | ( |  | subsys | ) |

Value:
__attribute__ ((constructor)) \
static void logsys_subsys_init (void) \
{ \
logsys_subsys_id = \
_logsys_subsys_create ((subsys), __FILE__); \
if (logsys_subsys_id == -1) { \
fprintf (stderr, \
"Unable to create logging subsystem: %s.\n", subsys); \
exit (-1); \
} \
}
__attribute__
typedef __attribute__

The LOGSYS_DECLARE_SUBSYS macro.

Parameters

  subsys |

Definition at line 306 of file logsys.h.

## LOGSYS_DECLARE_SYSTEM

#define LOGSYS_DECLARE_SYSTEM | ( |  | name,
|  |  | mode,
|  |  | syslog_facility,
|  |  | syslog_priority )

Value:
QB_LOG_INIT_DATA(logsys_qb_init); \
__attribute__ ((constructor)) \
static void logsys_system_init (void) \
{ \
if (_logsys_system_setup (name,mode,syslog_facility,syslog_priority) < 0) { \
fprintf (stderr, \
"Unable to setup logging system: %s.\n", name); \
exit (-1); \
} \
}
_logsys_system_setup
int _logsys_system_setup(const char *mainsystem, unsigned int mode, int syslog_facility, int syslog_priority)
_logsys_system_setup
Definition logsys.c:302

The LOGSYS_DECLARE_SYSTEM macro.

Parameters

  name |
  mode |
  syslog_facility |
  syslog_priority |

Definition at line 290 of file logsys.h.

## LOGSYS_LEVEL_ALERT

#define LOGSYS_LEVEL_ALERT LOG_ALERT

Definition at line 70 of file logsys.h.

## LOGSYS_LEVEL_CRIT

#define LOGSYS_LEVEL_CRIT LOG_CRIT

Definition at line 71 of file logsys.h.

Referenced by totemknet_finalize(), and totemknet_initialize().

## LOGSYS_LEVEL_DEBUG

#define LOGSYS_LEVEL_DEBUG LOG_DEBUG

Definition at line 76 of file logsys.h.

Referenced by cs_ipcs_service_init(), main(), totemconfig_configure_new_params(), totemip_parse(), totemknet_configure_log_level(), totemknet_crypto_reconfigure_phase(), totemknet_member_add(), totemknet_member_remove(), totemsrp_initialize(), and totemudpu_member_remove().

## LOGSYS_LEVEL_EMERG

#define LOGSYS_LEVEL_EMERG LOG_EMERG

Definition at line 69 of file logsys.h.

## LOGSYS_LEVEL_ERROR

#define LOGSYS_LEVEL_ERROR LOG_ERR

Definition at line 72 of file logsys.h.

Referenced by _corosync_exit_error(), corosync_service_defaults_link_and_init(), cs_ipcs_service_init(), main(), stats_map_track_add(), stats_map_track_delete(), sync_init(), totemknet_configure_log_level(), totemknet_crypto_reconfigure_phase(), totemknet_finalize(), totemknet_ifaces_get(), totemknet_member_add(), and totemknet_member_remove().

## LOGSYS_LEVEL_INFO

#define LOGSYS_LEVEL_INFO LOG_INFO

Definition at line 75 of file logsys.h.

Referenced by main(), and totemknet_initialize().

## LOGSYS_LEVEL_NOTICE

#define LOGSYS_LEVEL_NOTICE LOG_NOTICE

Definition at line 74 of file logsys.h.

Referenced by _corosync_exit_error(), corosync_service_link_and_init(), main(), totemudpu_member_add(), and totemudpu_member_remove().

## LOGSYS_LEVEL_TRACE

#define LOGSYS_LEVEL_TRACE LOG_TRACE

Definition at line 77 of file logsys.h.

Referenced by main().

## LOGSYS_LEVEL_WARNING

#define LOGSYS_LEVEL_WARNING LOG_WARNING

Definition at line 73 of file logsys.h.

Referenced by logsys_reopen_log_files(), main(), totemknet_initialize(), and totemknet_nodestatus_get().

## LOGSYS_MAX_PERROR_MSG_LEN

#define LOGSYS_MAX_PERROR_MSG_LEN 128

Definition at line 87 of file logsys.h.

## LOGSYS_MAX_SUBSYS_COUNT

#define LOGSYS_MAX_SUBSYS_COUNT 32

Definition at line 85 of file logsys.h.

Referenced by _logsys_subsys_create(), _logsys_system_setup(), logsys_config_apply(), logsys_config_debug_set(), logsys_config_file_set(), logsys_config_logfile_priority_set(), logsys_config_mode_set(), logsys_config_syslog_priority_set(), logsys_format_set(), logsys_priority_name_get(), logsys_reopen_log_files(), logsys_system_fini(), and logsys_thread_start().

## LOGSYS_MAX_SUBSYS_NAMELEN

#define LOGSYS_MAX_SUBSYS_NAMELEN 64

Definition at line 86 of file logsys.h.

Referenced by _logsys_subsys_create(), and _logsys_system_setup().

## LOGSYS_MODE_FORK

#define LOGSYS_MODE_FORK (1<<3)

Definition at line 63 of file logsys.h.

## LOGSYS_MODE_OUTPUT_FILE

#define LOGSYS_MODE_OUTPUT_FILE (1<<0)

Definition at line 60 of file logsys.h.

## LOGSYS_MODE_OUTPUT_STDERR

#define LOGSYS_MODE_OUTPUT_STDERR (1<<1)

Definition at line 61 of file logsys.h.

Referenced by _logsys_system_setup(), and LOGSYS_DECLARE_SYSTEM().

## LOGSYS_MODE_OUTPUT_SYSLOG

#define LOGSYS_MODE_OUTPUT_SYSLOG (1<<2)

Definition at line 62 of file logsys.h.

Referenced by _logsys_system_setup(), and LOGSYS_DECLARE_SYSTEM().

## LOGSYS_MODE_THREADED

#define LOGSYS_MODE_THREADED (1<<4)

Definition at line 64 of file logsys.h.

## LOGSYS_PERROR

#define LOGSYS_PERROR | ( |  | err_num,
|  |  | level,
|  |  | fmt,
|  |  | args... )

Value:
do { \
char _error_str[LOGSYS_MAX_PERROR_MSG_LEN]; \
const char *_error_ptr = qb_strerror_r(err_num, _error_str, sizeof(_error_str)); \
qb_log(level, fmt ": %s (%d)", ##args, _error_ptr, err_num); \
} while(0)
LOGSYS_MAX_PERROR_MSG_LEN
#define LOGSYS_MAX_PERROR_MSG_LEN
Definition logsys.h:87

The LOGSYS_PERROR macro.

Parameters

  err_num |
  level |
  fmt |
  args |

Definition at line 326 of file logsys.h.

Referenced by logsys_reopen_log_files(), and main().

## TRACE1

#define TRACE1 | ( |  | format,
|  |  | args... )

Value:
qb_log(LOG_TRACE, "TRACE1:" #format, ##args)

Definition at line 335 of file logsys.h.

## TRACE2

#define TRACE2 | ( |  | format,
|  |  | args... )

Value:
qb_log(LOG_TRACE, "TRACE2:" #format, ##args)

Definition at line 336 of file logsys.h.

## TRACE3

#define TRACE3 | ( |  | format,
|  |  | args... )

Value:
qb_log(LOG_TRACE, "TRACE3:" #format, ##args)

Definition at line 337 of file logsys.h.

## TRACE4

#define TRACE4 | ( |  | format,
|  |  | args... )

Value:
qb_log(LOG_TRACE, "TRACE4:" #format, ##args)

Definition at line 338 of file logsys.h.

## TRACE5

#define TRACE5 | ( |  | format,
|  |  | args... )

Value:
qb_log(LOG_TRACE, "TRACE5:" #format, ##args)

Definition at line 339 of file logsys.h.

## TRACE6

#define TRACE6 | ( |  | format,
|  |  | args... )

Value:
qb_log(LOG_TRACE, "TRACE6:" #format, ##args)

Definition at line 340 of file logsys.h.

## TRACE7

#define TRACE7 | ( |  | format,
|  |  | args... )

Value:
qb_log(LOG_TRACE, "TRACE7:" #format, ##args)

Definition at line 341 of file logsys.h.

## TRACE8

#define TRACE8 | ( |  | format,
|  |  | args... )

Value:
qb_log(LOG_TRACE, "TRACE8:" #format, ##args)

Definition at line 342 of file logsys.h.

## Function Documentation

## _logsys_config_subsys_get()

int _logsys_config_subsys_get | ( | const char * | subsys | ) |

extern

_logsys_config_subsys_get

Parameters

  subsys |

Returns

Definition at line 457 of file logsys.c.

References logsys_logger::subsys.

Referenced by logsys_config_mode_get().

## _logsys_subsys_create()

int _logsys_subsys_create | ( | const char * | subsys,
|  | const char * | filename )

extern

_logsys_subsys_create

Parameters

  subsys |
  filename |

Returns

Definition at line 427 of file logsys.c.

References LOGSYS_MAX_SUBSYS_COUNT, LOGSYS_MAX_SUBSYS_NAMELEN, and logsys_logger::subsys.

Referenced by _logsys_system_setup(), main(), and totemknet_initialize().

## _logsys_system_setup()

int _logsys_system_setup | ( | const char * | mainsystem,
|  | unsigned int | mode,
|  | int | syslog_facility,
|  | int | syslog_priority )

extern

_logsys_system_setup

Parameters

  mainsystem |
  mode |
  syslog_facility |
  syslog_priority |

Returns

Definition at line 302 of file logsys.c.

References _logsys_subsys_create(), logsys_logger::init_status, IPC_LOGSYS_SIZE, LOGSYS_DEBUG_OFF, logsys_format_set(), LOGSYS_LOGGER_INIT_DONE, LOGSYS_LOGGER_NEEDS_INIT, LOGSYS_MAX_SUBSYS_COUNT, LOGSYS_MAX_SUBSYS_NAMELEN, LOGSYS_MODE_OUTPUT_STDERR, LOGSYS_MODE_OUTPUT_SYSLOG, logsys_logger::mode, logsys_logger::subsys, and logsys_logger::syslog_priority.

## logsys_blackbox_postfork()

void logsys_blackbox_postfork | ( | void |  | ) |

extern

Definition at line 869 of file logsys.c.

Referenced by main().

## logsys_blackbox_prefork()

void logsys_blackbox_prefork | ( | void |  | ) |

extern

Definition at line 863 of file logsys.c.

Referenced by main().

## logsys_blackbox_set()

void logsys_blackbox_set | ( | int | enable | ) |

extern

Definition at line 853 of file logsys.c.

## logsys_config_apply()

void logsys_config_apply | ( | void |  | ) |

logsys_config_apply

Definition at line 766 of file logsys.c.

References LOGSYS_MAX_SUBSYS_COUNT, and logsys_logger::subsys.

Referenced by main().

## logsys_config_debug_get()

int logsys_config_debug_get | ( | const char * | subsys | ) |

extern

Return the debug flag for this subsys.

Parameters

  subsys |

Returns
  LOGSYS_DEBUG_OFF | LOGSYS_DEBUG_ON | LOGSYS_DEBUG_TRACE

Definition at line 780 of file logsys.c.

References logsys_logger::subsys.

Referenced by totemknet_configure_log_level().

## logsys_config_debug_set()

int logsys_config_debug_set | ( | const char * | subsys,
|  | unsigned int | value )

extern

enabling debug, disable message priority filtering.

everything is sent everywhere. priority values for file and syslog are not overwritten.

Parameters

  subsys |
  value |

Returns

Definition at line 795 of file logsys.c.

References logsys_logger::debug, LOGSYS_MAX_SUBSYS_COUNT, and logsys_logger::subsys.

## logsys_config_file_set()

int logsys_config_file_set | ( | const char * | subsys,
|  | const char ** | error_string,
|  | const char * | file )

extern

to close a logfile, just invoke this function with a NULL file or if you want to change logfile, the old one will be closed for you.

Parameters

  subsys |
  error_string |
  file |

Returns

Definition at line 520 of file logsys.c.

References LOGSYS_MAX_SUBSYS_COUNT, and logsys_logger::subsys.

## logsys_config_logfile_priority_set()

int logsys_config_logfile_priority_set | ( | const char * | subsys,
|  | unsigned int | priority )

extern

logsys_config_logfile_priority_set

Parameters

  subsys |
  priority |

Returns

Definition at line 667 of file logsys.c.

References LOGSYS_MAX_SUBSYS_COUNT, and logsys_logger::subsys.

## logsys_config_mode_get()

unsigned int logsys_config_mode_get | ( | const char * | subsys | ) |

extern

logsys_config_mode_get

Parameters

  subsys |

Returns

Definition at line 508 of file logsys.c.

References _logsys_config_subsys_get(), and logsys_logger::subsys.

## logsys_config_mode_set()

int logsys_config_mode_set | ( | const char * | subsys,
|  | unsigned int | mode )

extern

logsys_config_mode_set

Parameters

  subsys |
  mode |

Returns

Definition at line 489 of file logsys.c.

References LOGSYS_MAX_SUBSYS_COUNT, logsys_logger::mode, and logsys_logger::subsys.

## logsys_config_syslog_facility_set()

int logsys_config_syslog_facility_set | ( | const char * | subsys,
|  | unsigned int | facility )

extern

per system/subsystem settings.

NOTE: once a subsystem is created and configured, changing the default does NOT affect the subsystems.

Pass a NULL subsystem to change them all

Parameters

  subsys |
  facility |

Returns

Definition at line 635 of file logsys.c.

## logsys_config_syslog_priority_set()

int logsys_config_syslog_priority_set | ( | const char * | subsys,
|  | unsigned int | priority )

extern

logsys_config_syslog_priority_set

Parameters

  subsys |
  priority |

Returns

Definition at line 642 of file logsys.c.

References LOGSYS_MAX_SUBSYS_COUNT, and logsys_logger::subsys.

## logsys_format_get()

char * logsys_format_get | ( | void |  | ) |

extern

logsys_format_get

Returns

Definition at line 630 of file logsys.c.

## logsys_format_set()

int logsys_format_set | ( | const char * | format | ) |

extern

configuration bits that can only be done for the whole system

Parameters

  format |

Returns

Definition at line 571 of file logsys.c.

References LOGSYS_MAX_SUBSYS_COUNT, and logsys_logger::target_id.

Referenced by _logsys_system_setup().

## logsys_priority_id_get()

int logsys_priority_id_get | ( | const char * | name | ) |

extern

logsys_priority_id_get

Parameters

  name |

Returns

Definition at line 819 of file logsys.c.

## logsys_priority_name_get()

const char * logsys_priority_name_get | ( | unsigned int | priority | ) |

extern

logsys_priority_name_get

Parameters

  priority |

Returns

References LOGSYS_MAX_SUBSYS_COUNT.

## logsys_reopen_log_files()

cs_error_t logsys_reopen_log_files | ( | void |  | ) |

extern

Definition at line 875 of file logsys.c.

References CS_ERR_NOT_SUPPORTED, CS_OK, logsys_logger::logfile, LOGSYS_LEVEL_WARNING, LOGSYS_MAX_SUBSYS_COUNT, LOGSYS_PERROR, qb_to_cs_error(), and logsys_logger::target_id.

## logsys_system_fini()

void logsys_system_fini | ( | void |  | ) |

extern

logsys_system_fini

Definition at line 284 of file logsys.c.

References logsys_logger::files, logsys_logger::logfile, and LOGSYS_MAX_SUBSYS_COUNT.

Referenced by _corosync_exit_error(), and main().

## logsys_thread_start()

int logsys_thread_start | ( | void |  | ) |

extern

logsys_thread_start

Returns

Definition at line 831 of file logsys.c.

References LOGSYS_MAX_SUBSYS_COUNT, and logsys_logger::target_id.

Referenced by main().