logsys.c File Reference
`#include <config.h>`
`#include <stdint.h>`
`#include <ctype.h>`
`#include <assert.h>`
`#include <stdio.h>`
`#include <string.h>`
`#include <qb/qbdefs.h>`
`#include <qb/qbutil.h>`
`#include <qb/qblog.h>`
`#include <corosync/logsys.h>`
Include dependency graph for logsys.c:

Go to the source code of this file.

## Data Structures

struct | syslog_names
struct | logsys_logger

## Macros

#define | MAX_FILES_PER_SUBSYS 32
#define | IPC_LOGSYS_SIZE 8192*1024
#define | LOGSYS_LOGGER_INIT_DONE 0
#define | LOGSYS_LOGGER_NEEDS_INIT 1

## Functions

void | logsys_system_fini (void)
| logsys_system_fini
int | _logsys_system_setup (const char *mainsystem, unsigned int mode, int syslog_facility, int syslog_priority)
| _logsys_system_setup
int | _logsys_subsys_create (const char *subsys, const char *filename)
| _logsys_subsys_create
int | _logsys_config_subsys_get (const char *subsys)
| _logsys_config_subsys_get
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
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_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_logfile_priority_set (const char *subsys, unsigned int priority)
| logsys_config_logfile_priority_set
void | logsys_config_apply (void)
| logsys_config_apply
int | logsys_config_debug_get (const char *subsys)
| Return the debug flag for this subsys.
int | logsys_config_debug_set (const char *subsys, unsigned int debug)
| enabling debug, disable message priority filtering.
int | logsys_priority_id_get (const char *name)
| logsys_priority_id_get
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

## IPC_LOGSYS_SIZE

#define IPC_LOGSYS_SIZE 8192*1024

Definition at line 80 of file logsys.c.

Referenced by _logsys_system_setup().

## LOGSYS_LOGGER_INIT_DONE

#define LOGSYS_LOGGER_INIT_DONE 0

Definition at line 102 of file logsys.c.

Referenced by _logsys_system_setup().

## LOGSYS_LOGGER_NEEDS_INIT

#define LOGSYS_LOGGER_NEEDS_INIT 1

Definition at line 103 of file logsys.c.

Referenced by _logsys_system_setup().

## MAX_FILES_PER_SUBSYS

#define MAX_FILES_PER_SUBSYS 32

Definition at line 76 of file logsys.c.

## Function Documentation

## _logsys_config_subsys_get()

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

_logsys_config_subsys_get

Parameters

  subsys |

Returns

Definition at line 469 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 )

_logsys_subsys_create

Parameters

  subsys |
  filename |

Returns

Definition at line 435 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 )

_logsys_system_setup

Parameters

  mainsystem |
  mode |
  syslog_facility |
  syslog_priority |

Returns

Definition at line 304 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 |  | ) |

Definition at line 903 of file logsys.c.

Referenced by main().

## logsys_blackbox_prefork()

void logsys_blackbox_prefork | ( | void |  | ) |

Definition at line 897 of file logsys.c.

Referenced by main().

## logsys_blackbox_set()

void logsys_blackbox_set | ( | int | enable | ) |

Definition at line 883 of file logsys.c.

## logsys_config_apply()

void logsys_config_apply | ( | void |  | ) |

logsys_config_apply

Definition at line 792 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 806 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 )

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

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

logsys_config_logfile_priority_set

Parameters

  subsys |
  priority |

Returns

Definition at line 691 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 | ) |

logsys_config_mode_get

Parameters

  subsys |

Returns

Definition at line 527 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 )

logsys_config_mode_set

Parameters

  subsys |
  mode |

Returns

Definition at line 505 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 )

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 657 of file logsys.c.

## logsys_config_syslog_priority_set()

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

logsys_config_syslog_priority_set

Parameters

  subsys |
  priority |

Returns

Definition at line 664 of file logsys.c.

References LOGSYS_MAX_SUBSYS_COUNT, and logsys_logger::subsys.

## logsys_format_get()

char * logsys_format_get | ( | void |  | ) |

logsys_format_get

Returns

Definition at line 652 of file logsys.c.

## logsys_format_set()

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

configuration bits that can only be done for the whole system

Parameters

  format |

Returns

Definition at line 593 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 | ) |

logsys_priority_id_get

Parameters

  name |

Returns

Definition at line 849 of file logsys.c.

## logsys_reopen_log_files()

cs_error_t logsys_reopen_log_files | ( | void |  | ) |

Definition at line 909 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 |  | ) |

logsys_system_fini

Definition at line 286 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 |  | ) |

logsys_thread_start

Returns

Definition at line 861 of file logsys.c.

References LOGSYS_MAX_SUBSYS_COUNT, and logsys_logger::target_id.

Referenced by main().