- Introduction
- Features
- Requirements
- How It Works
- Setup and Usage
- Project Structure
- Example Output
- License
This is a Multithreaded Logging System implemented in C++. The system efficiently handles logging in multi-threaded environments by ensuring thread safety and high performance using a dedicated logging thread and a thread-safe queue.
- Supports concurrent logging from multiple threads.
- Uses a thread-safe queue for handling log messages.
- Writes logs asynchronously to avoid blocking the main application.
- Adjustable log levels:
INFO
,DEBUG
,WARN
,ERROR
. - Logs are written to a file or console.
-
Singleton Design Pattern:
- Ensures only one instance of the Logger exists throughout the application.
-
Thread-Safe Logging:
- A mutex protects access to the log queue.
- The worker thread processes logs from the queue and writes them to the file.
-
Producer-Consumer Model:
- Main threads (producers) add log messages to the queue.
- The worker thread (consumer) processes messages from the queue.
-
Graceful Shutdown:
- The
stop()
method ensures all logs are processed before shutting down.
- The
- Operating System: macOS/Linux/Windows
- Compiler: C++17 or later
- Build Tools: Make, CMake, or any equivalent tool.
- Dependencies: Standard Template Library (STL).
- Multiple threads send log messages to a shared thread-safe queue.
- A dedicated logging thread retrieves messages from the queue.
- The logger writes messages to a log file or the console.
- Ensures thread safety using mutex locks and condition variables.
git clone https://github.com/username/multithreaded-logging-system.git
cd multithreaded-logging-system