CTS-SAT-1-OBC-Firmware
Loading...
Searching...
No Matches
lazy_file_log_sink.c File Reference
#include <stdint.h>
#include <stdio.h>
#include "log/log_a_logging_error.h"
#include "log/lazy_file_log_sink.h"
#include "log/log.h"
#include "timekeeping/timekeeping.h"
#include "littlefs/lfs.h"
#include "littlefs/littlefs_helper.h"
#include "main.h"
Include dependency graph for lazy_file_log_sink.c:

Classes

struct  LOG_file_context_struct_t

Functions

static int8_t LOG_close_current_log_file (void)
 Closed the current log file.
static int8_t LOG_open_new_log_file_and_set_as_current (void)
 Opens a new timestamped log file, and sets it as the current log file.
static int8_t LOG_ensure_current_log_file_is_open ()
static int8_t LOG_write_to_current_log_file (const char *msg, uint16_t msg_length)
 Writes to the current log file.
void LOG_to_file_lazy (const char filename[], const char msg[])
 Write a log message to an LFS log file.
int8_t LOG_sync_current_log_file (void)
 Syncs the current log file.
void LOG_subtask_handle_sync_and_close_of_current_log_file ()
 Flush the current LittleFS log file(s), forcing a write to flash.

Variables

uint32_t LOG_file_flush_interval_sec = 60
uint32_t LOG_file_rotation_interval_sec = 1800
static LOG_file_context_struct_t LOG_current_log_file_ctx

Function Documentation

◆ LOG_close_current_log_file()

int8_t LOG_close_current_log_file ( void )
static

Closed the current log file.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LOG_ensure_current_log_file_is_open()

int8_t LOG_ensure_current_log_file_is_open ( )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LOG_open_new_log_file_and_set_as_current()

int8_t LOG_open_new_log_file_and_set_as_current ( void )
static

Opens a new timestamped log file, and sets it as the current log file.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LOG_subtask_handle_sync_and_close_of_current_log_file()

void LOG_subtask_handle_sync_and_close_of_current_log_file ( )

Flush the current LittleFS log file(s), forcing a write to flash.

Note
This function is meant to be called periodically in an RTOS task.
This function can be called very frequently. It tracks its own internal configuration.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LOG_sync_current_log_file()

int8_t LOG_sync_current_log_file ( void )

Syncs the current log file.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LOG_to_file_lazy()

void LOG_to_file_lazy ( const char filename[],
const char msg[] )

Write a log message to an LFS log file.

Parameters
msgThe message to be logged
Note
LFS files are not updated until the file is closed or synced. Syncing is done periodically in the rtos_background_upkeep task.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LOG_write_to_current_log_file()

int8_t LOG_write_to_current_log_file ( const char * msg,
uint16_t msg_length )
static

Writes to the current log file.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ LOG_current_log_file_ctx

LOG_file_context_struct_t LOG_current_log_file_ctx
static

◆ LOG_file_flush_interval_sec

uint32_t LOG_file_flush_interval_sec = 60

◆ LOG_file_rotation_interval_sec

uint32_t LOG_file_rotation_interval_sec = 1800