|
Logger System 0.1.3
High-performance C++20 thread-safe logging system with asynchronous capabilities
|
Logger crash protection demonstration. More...
#include <iostream>#include <thread>#include <chrono>#include <random>#include <vector>#include <memory>#include <atomic>#include <fstream>#include "interfaces/logger_crash_safety.h"#include "logger/logger.h"#include "logger/writers/console_writer.h"#include "logger/writers/file_writer.h"#include <kcenon/common/interfaces/logger_interface.h>
Go to the source code of this file.
Functions | |
| void | simulate_logger_crash () |
| void | simulate_file_corruption () |
| void | simulate_disk_full () |
| void | normal_logging_task (int task_id, std::shared_ptr< logger > logger_instance) |
| void | heavy_logging_task (int task_id, std::shared_ptr< logger > logger_instance) |
| void | potentially_crashing_logging_task (int task_id, std::shared_ptr< logger > logger_instance) |
| void | on_logger_crash (const std::string &logger_name) |
| void | flush_main_logger () |
| void | backup_main_logger (const std::string &backup_path) |
| void | save_emergency_state () |
| int | main () |
Variables | |
| std::atomic< bool > | logging_active {true} |
| std::atomic< int > | logs_written {0} |
| std::atomic< int > | emergency_logs {0} |
Logger crash protection demonstration.
Definition in file main.cpp.
| void backup_main_logger | ( | const std::string & | backup_path | ) |
Definition at line 155 of file main.cpp.
Referenced by main().

| void flush_main_logger | ( | ) |
Definition at line 151 of file main.cpp.
Referenced by main().

| void heavy_logging_task | ( | int | task_id, |
| std::shared_ptr< logger > | logger_instance ) |
Definition at line 80 of file main.cpp.
References logs_written.
Referenced by main().

| int main | ( | ) |
Definition at line 172 of file main.cpp.
References backup_main_logger(), emergency_logs, flush_main_logger(), heavy_logging_task(), logging_active, logs_written, normal_logging_task(), potentially_crashing_logging_task(), and simulate_file_corruption().

| void normal_logging_task | ( | int | task_id, |
| std::shared_ptr< logger > | logger_instance ) |
Definition at line 64 of file main.cpp.
References logs_written.
Referenced by main().

| void on_logger_crash | ( | const std::string & | logger_name | ) |
Definition at line 141 of file main.cpp.
References emergency_logs, and logging_active.
| void potentially_crashing_logging_task | ( | int | task_id, |
| std::shared_ptr< logger > | logger_instance ) |
Definition at line 102 of file main.cpp.
References emergency_logs, logs_written, simulate_file_corruption(), and simulate_logger_crash().
Referenced by main().


| void save_emergency_state | ( | ) |
Definition at line 166 of file main.cpp.
References emergency_logs, and logs_written.
| void simulate_disk_full | ( | ) |
Definition at line 56 of file main.cpp.
| void simulate_file_corruption | ( | ) |
Definition at line 46 of file main.cpp.
Referenced by main(), and potentially_crashing_logging_task().

| void simulate_logger_crash | ( | ) |
Definition at line 41 of file main.cpp.
Referenced by potentially_crashing_logging_task().

| std::atomic<int> emergency_logs {0} |
Definition at line 38 of file main.cpp.
Referenced by main(), on_logger_crash(), potentially_crashing_logging_task(), and save_emergency_state().
| std::atomic<bool> logging_active {true} |
Definition at line 36 of file main.cpp.
Referenced by main(), and on_logger_crash().
| std::atomic<int> logs_written {0} |
Definition at line 37 of file main.cpp.
Referenced by heavy_logging_task(), main(), normal_logging_task(), potentially_crashing_logging_task(), and save_emergency_state().