Skip to content
built fromSolidSyslogCore«struct»SolidSyslogConfig«interface»SolidSyslogBuffer«interface»SolidSyslogSender«interface»SolidSyslogStore«interface»SolidSyslogStructuredData0..*

File SolidSyslog.h

FileList > Core > Interface > SolidSyslog.h

The application logging API: SolidSyslog_Log / SolidSyslog_LogWithSd to emit an event, SolidSyslog_Service to drive delivery, and the SolidSyslogMessage struct.

  • #include "SolidSyslogExternC.h"
  • #include "SolidSyslogPrival.h"
  • #include "SolidSyslogServiceStatus.h"
  • #include <stddef.h>

Classes

Type Name
struct SolidSyslogMessage
One event to log.

Public Functions Documentation

SolidSyslog_Log

Format message and hand it to the configured Buffer.

void SolidSyslog_Log (
    struct SolidSyslog * handle,
    const struct SolidSyslogMessage * message
) 

Whether this blocks depends on that Buffer: a PassthroughBuffer sends inline; a CircularBuffer enqueues and returns, leaving delivery to SolidSyslog_Service. A device that answers off from SolidSyslogConfig.GetCaptureState has the record dropped before it is formatted. Concurrent calls are safe only if the configured Buffer is thread-safe (e.g. a CircularBuffer with a real Mutex). A NULL handle or message is reported via SolidSyslog_Error and otherwise ignored.


SolidSyslog_LogWithSd

As SolidSyslog_Log, but also attaches sd [0..sdCount) as caller-built SD-ELEMENTs to this one message, emitted after the per-instance SDs registered at Create.

void SolidSyslog_LogWithSd (
    struct SolidSyslog * handle,
    const struct SolidSyslogMessage * message,
    struct SolidSyslogStructuredData ** sd,
    size_t sdCount
) 

The SD objects need only live for the duration of the call. (SolidSyslog_Log is this with sd = NULL, sdCount = 0.)


SolidSyslog_Service

Run one servicing pass and return an advisory hint for driving an event-driven loop.

enum SolidSyslogServiceStatus SolidSyslog_Service (
    struct SolidSyslog * handle
) 

A pass asks whether the device captures (SolidSyslogConfig.GetCaptureState), then reports the library's own events that are waiting (see SolidSyslogConfig.IsEventReportingOn), drains the buffer into the store, or straight to the sender when the store keeps nothing, then attempts one send from the store. A device still undecided has its buffer, and the reports, held for a later pass. The hint is never load-bearing: each call works from the live buffer and store and from the record it holds, so a missed or spurious wake only delays, and a fixed-delay poll loop may ignore the return. A NULL handle is reported and returns IDLE.

Return value:

  • SOLIDSYSLOG_SERVICE_IDLE Nothing left anywhere - no record held, buffered or stored, and no event of the library's own waiting - or the reporting switch turned a report down this pass, which leaves every event waiting, those raised later in the pass too; wait for the next Log. Turning reporting back on does not wake a loop waiting here: the next Log, or a poll, makes the report.
  • SOLIDSYSLOG_SERVICE_READY There is more to do: the buffer was read this pass, the store still has unsent after a send, or an event of the library's own is waiting to be reported; loop again.
  • SOLIDSYSLOG_SERVICE_BLOCKED A record is waiting on the sender. With a store that keeps nothing, a direct send failed and Service holds the record. Otherwise the buffer was idle and the store could not move a record: a send was attempted and failed, or the store holds records it cannot hand out yet. A record held back because the device does not yet know where its collector is (SolidSyslogConfig.IsDestinationKnown) counts as waiting on the sender, and so does a pass that read nothing from the buffer because the device has not decided whether it captures (SolidSyslogConfig.GetCaptureState). Back off and call again later. A Log also wakes it.
  • SOLIDSYSLOG_SERVICE_HALTED The logger has stopped: a queue refused a record while the discard policy answered HALT, and the pass that saw it raised SOLIDSYSLOG_CAT_LOGGER_HALTED and called OnHalt. Nothing moves until the policy answers otherwise, or the device restarts; alarm / slow heartbeat. The halt waits to be reported, as any event of the library's own does, until it lifts.

With a store that retains records, buffer drain out-ranks a send failure: a down sender never demotes the loop out of "keep draining" while the buffer still has records to move into the store. With a store that keeps nothing - a NullStore, or a BlockStore that has frozen - the buffer is the only queue. Service then stops at the first failed send, holds that record, and reads neither the buffer nor the store again until it has gone, so nothing overtakes it; records logged meanwhile wait in the buffer under its own policy.

Service never drops a report of the library's own; a sender that takes one decides its fate as it does a record's. One a retaining store loses, or refuses under its discard policy, goes to the sender instead, ahead of the records the store holds. Service holds it while the sender refuses it, or while that refusal has the logger halted, and offers it to the store again first on the next pass.

Call this from one task. SolidSyslog_Log is the only entry point designed to be called concurrently; everything reached from Service - the sender, the store, the stream and its credentials - runs single-threaded, and so does every Create and Destroy. A Destroy issued from another task while Service runs is outside the design whatever the config lock is set to, because that lock serialises pool slot walks and not the objects a walk is tearing down.



The documentation for this class was generated from the following file Core/Interface/SolidSyslog.h