Project

General

Profile

Actions

Feature #896

open

Add support for logging to syslog

Added by Hammel 28 days ago.

Status:
New
Priority:
High
Assignee:
Target version:
Start date:
11 Jul 2022
Due date:
% Done:

0%

Estimated time:
Severity:
03 - Medium

Description

This is pretty straight forward.

1. In the init function:
if ( isCLIFlagSet(CLI_SYSLOG) )
piboxSyslogInit();
2. In the shutdown function:
if ( isCLIFlagSet(CLI_SYSLOG) )
piboxSyslogShutdown();
3. In logger local:
/* ---- SYSLOG OUTPUT ---- */
if ( isCLIFlagSet(CLI_SYSLOG) ) {
if ( verbose >= type )
piboxSyslog(type, hdr, LogType[type], buf);
}
4. Then add the following functions:

/* * These functions are separate from piboxLogger to avoid namespace clashes.
*/
void
piboxSyslogInit() {
openlog("<appname>", LOG_PID, (LOG_USER | LOG_NOTICE | LOG_FACMASK));
}
void
piboxSyslog( int type, const char *hdr, const char *logtype, const char *buf ) {
syslog(SLOG[type], "%s %s %s", hdr, logtype, buf);
}
void
piboxSyslogShutdown() {
closelog();

The <appname> may require additional init handling to set the name, or we can get it from the cli args.

No data to display

Actions

Also available in: Atom PDF