#pragma once #ifdef __cplusplus #include #include #else #include #include #endif #include "sl/strategies.h" struct sl_buffer_strategy; struct sl_sink_strategy; struct sl_overflow_strategy; struct sl_output_strategy; #ifdef __cplusplus namespace sl { using buffer_strategy = sl_buffer_strategy; using sink_strategy = sl_sink_strategy; using overflow_strategy = sl_overflow_strategy; using output_strategy = sl_output_strategy; } #else typedef struct sl_buffer_strategy sl_buffer_strategy; typedef struct sl_sink_strategy sl_sink_strategy; typedef struct sl_overflow_strategy sl_overflow_strategy; typedef struct sl_output_strategy sl_output_strategy; #endif #ifdef __cplusplus extern "C" { #endif /** * @brief Constructs a buffer strategy from C * @param strategy The type of strategy * @param filename A file describing the strategy, ignored if SL_BUFFER_TYPE is SL_INTERNAL, optional if SL_BUFFER_TYPE is SL_SHARED * @return a strategy token for building a logger */ sl_buffer_strategy* sl_create_buffer_strategy(SL_BUFFER_TYPE strategy, char *filename); /** * @brief Constructs a sink strategy for how to handle IO in the logger * @param strategy The type of strategy * @return a strategy token to build a logger */ sl_sink_strategy* sl_create_sink_strategy(SL_SINK_IO_TYPE strategy); /** * @brief Constructs an overflow strategy for how to handle the edge case of a full buffer * @param strategy The type of strategy * @return a strategy token to build a logger */ sl_overflow_strategy* sl_create_overflow_strategy(SL_ON_SINK_FULL strategy); /** * @brief Constructs a strategy that will direct where data is logged and how it will be split * @param strategy The strategy to use * @param strategy_parameter Either the amount of hours to keep in the same file, or the file size in kilobytes * @param output_directory The directory where the logs will be written * @return a strategy token to build a logger */ sl_output_strategy* sl_create_output_strategy(SL_ROLL_LOGS strategy, uint64_t strategy_parameter, char* output_directory); /** * @brief Constructs and registers a logger, readily available immediately * @param internal_id The ID with which you want to refer to the logger to access it as fast as possible * @param external_id The ID which will be part of the logs filename * @param strategies Collect the 4 tokens and reunite them into the hero's sword that will slay every other logger */ void sl_register_logger(int internal_id, char* external_id, sl_buffer_strategy*, sl_sink_strategy*, sl_overflow_strategy*, sl_output_strategy*); #ifdef __cplusplus } #endif