Crinit -- Configurable Rootfs Init
Loading...
Searching...
No Matches
eloslog.c File Reference

(/usr/bin/git 2025-03-11, commit: 63aee44)

Implementation of elos event handling. More...

#include "eloslog.h"
#include <errno.h>
#include <pthread.h>
#include <safu/common.h>
#include <safu/ringbuffer.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "common.h"
#include "confparse.h"
#include "globopt.h"
Include dependency graph for eloslog.c:

Data Structures

struct  crinitElosEventThread_t
 

Macros

#define STR_HELPER(x)   #x
 
#define STR(x)   STR_HELPER(x)
 
#define CRINIT_MACHINE_ID_LENGTH   32
 
#define CRINIT_MACHINE_ID_FORMAT   "%" STR(CRINIT_MACHINE_ID_LENGTH) "s"
 

Functions

static int crinitFetchHWId (char *hwId)
 
static int crinitPublishEvent (void const *element, void const *data)
 
static void * crinitEloslogEventTransmitter (void *arg)
 
int crinitElosLog (crinitElosSeverityE_t severity, crinitElosEventMessageCodeE_t messageCode, uint64_t classification, const char *format,...)
 
int crinitEloslogInit (void)
 
int crinitEloslogActivate (bool e)
 

Variables

static bool crinitElosActivated = false
 Indicates if the elos connection and handler thread has been set up.
 
static pthread_mutex_t crinitElosActivatedLock = PTHREAD_MUTEX_INITIALIZER
 Mutex to guard crinitElosActivated.
 
static struct crinitElosEventThread_t crinitTinfo
 
static pthread_mutex_t crinitEloslogSessionLock = PTHREAD_MUTEX_INITIALIZER
 
static safuRingBuffer_t crinitElosEventBuffer
 
static pthread_mutex_t crinitEloslogTrCondLock = PTHREAD_MUTEX_INITIALIZER
 
static pthread_cond_t crinitEloslogTransmitCondition = PTHREAD_COND_INITIALIZER
 
static int crinitEloslogTransmitCounter = 0
 

Detailed Description

Implementation of elos event handling.

Macro Definition Documentation

◆ CRINIT_MACHINE_ID_FORMAT

#define CRINIT_MACHINE_ID_FORMAT   "%" STR(CRINIT_MACHINE_ID_LENGTH) "s"

◆ CRINIT_MACHINE_ID_LENGTH

#define CRINIT_MACHINE_ID_LENGTH   32

◆ STR

#define STR (   x)    STR_HELPER(x)

◆ STR_HELPER

#define STR_HELPER (   x)    #x

Function Documentation

◆ crinitElosLog()

int crinitElosLog ( crinitElosSeverityE_t  severity,
crinitElosEventMessageCodeE_t  messageCode,
uint64_t  classification,
const char *  format,
  ... 
)

Log a crinit event to elos.

Parameters
severityThe event severity.
messageCodeThe event message code.
classificationThe event classification bitmask.
formatFormat string to format remaining arguments.
Returns
Returns 0 on success, -1 otherwise.

◆ crinitEloslogActivate()

int crinitEloslogActivate ( bool  e)

Specify if events should be sent to Elos.

By default, Crinit will not connect to elos. If this is set to true, however, Crinit will connect and send events to the elos daemon.

Parameters
etrue if elos should be used, false otherwise.
Returns
Returns 0 on success, -1 otherwise.

◆ crinitEloslogEventTransmitter()

static void * crinitEloslogEventTransmitter ( void *  arg)
static

◆ crinitEloslogInit()

int crinitEloslogInit ( void  )

Initialize all components needed to handle event logging.

◆ crinitFetchHWId()

static int crinitFetchHWId ( char *  hwId)
inlinestatic

◆ crinitPublishEvent()

static int crinitPublishEvent ( void const *  element,
void const *  data 
)
inlinestatic

Variable Documentation

◆ crinitElosActivated

bool crinitElosActivated = false
static

Indicates if the elos connection and handler thread has been set up.

◆ crinitElosActivatedLock

pthread_mutex_t crinitElosActivatedLock = PTHREAD_MUTEX_INITIALIZER
static

Mutex to guard crinitElosActivated.

◆ crinitElosEventBuffer

safuRingBuffer_t crinitElosEventBuffer
static

Ring buffer of elos event messages

◆ crinitEloslogSessionLock

pthread_mutex_t crinitEloslogSessionLock = PTHREAD_MUTEX_INITIALIZER
static

Mutex synchronizing elos connection

◆ crinitEloslogTransmitCondition

pthread_cond_t crinitEloslogTransmitCondition = PTHREAD_COND_INITIALIZER
static

Condition variable to block the transmitter thread until there are events to send

◆ crinitEloslogTransmitCounter

int crinitEloslogTransmitCounter = 0
static

Counter to account for condition variable signalling while it is not being waited on

◆ crinitEloslogTrCondLock

pthread_mutex_t crinitEloslogTrCondLock = PTHREAD_MUTEX_INITIALIZER
static

Mutex synchronizing access to the transmitter condition variable

◆ crinitTinfo

struct crinitElosEventThread_t crinitTinfo
static