KM3NeT CLB  2.0
KM3NeT CLB v2 Embedded Software
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
loghist.h File Reference

Stores logging history. More...

#include <stdbool.h>
#include <stdint.h>
#include "util/log.h"

Go to the source code of this file.

Macros

#define LH_BUFFER_LENGTH   16
 Maximum number of entries stored in memory.
 
#define LH_BUFFER_WIDTH   80
 Maximum width of the in memory log lines.
 

Functions

bool lhFlashInit ()
 Initializes the flash storage (may take a while).
 
bool lhFlashItStart (int count)
 Start the iteration through the flash entries. More...
 
bool lhFlashItNext (char *bufPtr, int bufSize)
 Get the next element. More...
 
void lhStore (LogLevel level, char *msg)
 Stores a line in the buffer, and in flash if activated.
 
char * lhGetLine (int idx)
 Returns a line from the in memory log, where index 0 is the last logged line. More...
 
uint32_t lhGetLineById (uint32_t lastId, char **logLinePtr)
 Returns the last log-line based on log-line ID. More...
 

Variables

bool lhEnableFlashWrite
 Boolean to enable to disable the writing of logging to the flash. More...
 

Detailed Description

Stores logging history.

It uses RAM (fast) and FLASH (log term)

Definition in file loghist.h.

Function Documentation

bool lhFlashItNext ( char *  bufPtr,
int  bufSize 
)

Get the next element.

Return values
trueNext log entry written to buffer.
falseNo new entry.

Definition at line 250 of file loghist.c.

bool lhFlashItStart ( int  count)

Start the iteration through the flash entries.

Parameters
countThe maximum number of entries you wish to retrieve.
Return values
trueSuccess
falseFailure, check error module.

Definition at line 230 of file loghist.c.

char* lhGetLine ( int  idx)

Returns a line from the in memory log, where index 0 is the last logged line.

The maximum number of idx is defined in SYS_LOG_BUFFER_LENGTH.

Parameters
idxIndex, 0 - last logged line.
Returns
A pointer to the logging entry, or NULL / empty string if there is none.

Definition at line 328 of file loghist.c.

uint32_t lhGetLineById ( uint32_t  lastId,
char **  logLinePtr 
)

Returns the last log-line based on log-line ID.

Returns from the log-buffer a single log line. The provided ID represents the log-line you last got returned, or 0 if you did not receive a line yet.

The provided character pointer-pointer will point to a log line, if available, or else NULL.

If there is any logging available, and which you did get yet, it will return the oldest still available logging, and return its ID. Usually this is lastId + 1.

If the lastId provided is older than what is available in the log buffer, the oldest available entry is returned, and the associated ID.

If the lastId provided is the last logged line, the returned log line ID is the same, and the log-line pointer will not be filled.

Note
this feature is especially for remote devices wishing to load the latest logging lines.
Parameters
lastIdThe last logID returned
logLinePtrA pointer pointer to be set
Returns
A new log-line ID.

Definition at line 214 of file loghist.c.

Variable Documentation

bool lhEnableFlashWrite

Boolean to enable to disable the writing of logging to the flash.

Set to true by default, but will only work after successful initialization of flash through lhFlashInit.

Definition at line 58 of file loghist.c.