Logger System 0.1.3
High-performance C++20 thread-safe logging system with asynchronous capabilities
Loading...
Searching...
No Matches
kcenon::logger::server::log_server Class Reference

Log server for receiving distributed log messages. More...

#include <log_server.h>

Collaboration diagram for kcenon::logger::server::log_server:
Collaboration graph

Public Member Functions

 log_server (const server_config &config={})
 
 ~log_server ()
 
bool start ()
 Start the log server.
 
void stop ()
 Stop the log server.
 
bool is_running () const
 Check if server is running.
 
const server_configget_config () const
 Get server configuration.
 

Private Member Functions

void worker_loop ()
 

Private Attributes

server_config config_
 
std::atomic< bool > running_ {false}
 
std::vector< std::thread > worker_threads_
 

Detailed Description

Log server for receiving distributed log messages.

Definition at line 36 of file log_server.h.

Constructor & Destructor Documentation

◆ log_server()

kcenon::logger::server::log_server::log_server ( const server_config & config = {})
inlineexplicit

Definition at line 43 of file log_server.h.

43{}) : config_(config) {}

◆ ~log_server()

kcenon::logger::server::log_server::~log_server ( )
inline

Definition at line 45 of file log_server.h.

45 {
46 stop();
47 }
void stop()
Stop the log server.
Definition log_server.h:72

References stop().

Here is the call graph for this function:

Member Function Documentation

◆ get_config()

const server_config & kcenon::logger::server::log_server::get_config ( ) const
inline

Get server configuration.

Definition at line 97 of file log_server.h.

97 {
98 return config_;
99 }

References config_.

◆ is_running()

bool kcenon::logger::server::log_server::is_running ( ) const
inline

Check if server is running.

Definition at line 90 of file log_server.h.

90 {
91 return running_.load();
92 }

References running_.

◆ start()

bool kcenon::logger::server::log_server::start ( )
inline

Start the log server.

Definition at line 52 of file log_server.h.

52 {
53 if (running_.load()) {
54 return false;
55 }
56
57 running_.store(true);
58
59 // Start worker threads
60 for (size_t i = 0; i < std::thread::hardware_concurrency(); ++i) {
61 worker_threads_.emplace_back([this]() {
63 });
64 }
65
66 return true;
67 }
std::vector< std::thread > worker_threads_
Definition log_server.h:40

References running_, worker_loop(), and worker_threads_.

Here is the call graph for this function:

◆ stop()

void kcenon::logger::server::log_server::stop ( )
inline

Stop the log server.

Definition at line 72 of file log_server.h.

72 {
73 if (!running_.load()) {
74 return;
75 }
76
77 running_.store(false);
78
79 for (auto& thread : worker_threads_) {
80 if (thread.joinable()) {
81 thread.join();
82 }
83 }
84 worker_threads_.clear();
85 }

References running_, and worker_threads_.

Referenced by ~log_server().

Here is the caller graph for this function:

◆ worker_loop()

void kcenon::logger::server::log_server::worker_loop ( )
inlineprivate

Definition at line 102 of file log_server.h.

102 {
103 while (running_.load()) {
104 // Worker implementation would go here
105 // For now, just sleep to simulate work
106 std::this_thread::sleep_for(std::chrono::milliseconds(100));
107 }
108 }

References running_.

Referenced by start().

Here is the caller graph for this function:

Member Data Documentation

◆ config_

server_config kcenon::logger::server::log_server::config_
private

Definition at line 38 of file log_server.h.

Referenced by get_config().

◆ running_

std::atomic<bool> kcenon::logger::server::log_server::running_ {false}
private

Definition at line 39 of file log_server.h.

39{false};

Referenced by is_running(), start(), stop(), and worker_loop().

◆ worker_threads_

std::vector<std::thread> kcenon::logger::server::log_server::worker_threads_
private

Definition at line 40 of file log_server.h.

Referenced by start(), and stop().


The documentation for this class was generated from the following file: