Project

General

Profile

Actions

Feature #896

closed

Add support for logging to syslog

Added by Hammel over 2 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Immediate
Assignee:
Target version:
Start date:
11 Jul 2022
Due date:
% Done:

100%

Estimated time:
Severity:
03 - Medium

Description

This is pretty straight forward.

1. In the init function:

    if ( log_flags & LOG_F_SYSLOG )
        piboxSyslogInit();

2. In the shutdown function:

    if ( log_flags & LOG_F_SYSLOG )
        piboxSyslogShutdown();

3. In logger local:

    /* ---- SYSLOG OUTPUT ---- */
    if ( log_flags & LOG_F_SYSLOG )
    {   
        if ( verbose >= type )
            piboxSyslog(type, hdr, LogType[type], buf);
    }

4. Add LOG_F_SYSLOG to log.h and the comment in piboxLoggerSetFlags().

5. 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.

Actions

Also available in: Atom PDF