|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Thread-safe log manager with timestamps. More...
#include <log.H>
Public Member Functions | |
| Log_Manager (FILE *_file_descriptor) | |
| Construct log manager for a file. | |
| ~Log_Manager () | |
| Destructor releases mutex. | |
| void | init_line (const char *format,...) |
| Write log line without newline (for multi-part messages). | |
| void | write_line (const char *format,...) |
| Write complete log line with newline. | |
Private Member Functions | |
| void | get_time () |
| Get current time as formatted string. | |
Private Attributes | |
| FILE * | file_descriptor |
| Output file descriptor. | |
| pthread_mutex_t | mutex |
| Thread synchronization mutex. | |
| char | print_buffer [Max_Log_Line_Length] |
| Message buffer. | |
| char | time_buffer [Max_Time_Line_Length] |
| Timestamp buffer. | |
| size_t | num_lines |
| Lines written (not used) | |
| size_t | max_num_lines |
| Max lines (not used) | |
Static Private Attributes | |
| static const short int | Max_Log_Line_Length = 512 |
| Max message length. | |
| static const short int | Max_Time_Line_Length = 61 |
| Max timestamp length. | |
Thread-safe log manager with timestamps.
Provides synchronized logging to a file descriptor with automatic timestamp generation and optional debug information.
All logging operations are protected by a mutex, making it safe for concurrent use from multiple threads.
TIMESTAMP (thread_id:pid): MESSAGETIMESTAMP (file:line:thread_id:pid): MESSAGE
|
inline |
Construct log manager for a file.
| _file_descriptor | Output file (e.g., stdout, stderr, or fopen result) |
Definition at line 130 of file log.H.
References init_mutex(), Aleph::maps(), and mutex.
|
inline |
Destructor releases mutex.
Definition at line 139 of file log.H.
References destroy_mutex(), and mutex.
|
inlineprivate |
Get current time as formatted string.
Formats time as: "Weekday Month Day Year HH:MM:SS AM/PM"
Definition at line 111 of file log.H.
References Aleph::maps(), Max_Time_Line_Length, and time_buffer.
Referenced by init_line(), and write_line().
Write log line without newline (for multi-part messages).
| format | Printf-style format string |
| ... | Format arguments |
Definition at line 152 of file log.H.
References CRITICAL_SECTION, file, file_descriptor, get_time(), Aleph::maps(), mutex, and time_buffer.
Write complete log line with newline.
| format | Printf-style format string |
| ... | Format arguments |
Definition at line 187 of file log.H.
References CRITICAL_SECTION, file, file_descriptor, get_time(), Aleph::maps(), mutex, and time_buffer.
|
private |
Output file descriptor.
Definition at line 96 of file log.H.
Referenced by init_line(), and write_line().
|
private |
|
private |
Thread synchronization mutex.
Definition at line 98 of file log.H.
Referenced by Log_Manager(), ~Log_Manager(), init_line(), and write_line().
|
private |
|
private |
|
private |
Timestamp buffer.
Definition at line 101 of file log.H.
Referenced by get_time(), init_line(), and write_line().