CTaps 0.3.0
A C implementation of the Transport Services API (RFC 9621 - 9623)
Loading...
Searching...
No Matches
Logging

Log level configuration and file output. More...

Enumerations

enum  ct_log_level_enum_t {
  CT_LOG_TRACE = 0 , CT_LOG_DEBUG = 1 , CT_LOG_INFO = 2 , CT_LOG_WARN = 3 ,
  CT_LOG_ERROR = 4
}
 Log level enumeration for filtering log output. More...
 

Functions

void ct_set_log_level (ct_log_level_enum_t level)
 Set the minimum logging level for CTaps.
 
int ct_add_log_file (const char *file_path, ct_log_level_enum_t min_level)
 Add a file output destination for CTaps logs.
 

Detailed Description

Log level configuration and file output.

Enumeration Type Documentation

◆ ct_log_level_enum_t

Log level enumeration for filtering log output.

Log levels range from TRACE (most verbose) to ERROR (critical errors only). Setting a log level filters out all messages below that level.

Enumerator
CT_LOG_TRACE 

Trace-level debugging (most verbose)

CT_LOG_DEBUG 

Debug-level information.

CT_LOG_INFO 

Informational messages (default)

CT_LOG_WARN 

Warning messages.

CT_LOG_ERROR 

Error messages.

Definition at line 125 of file ctaps.h.

Function Documentation

◆ ct_add_log_file()

int ct_add_log_file ( const char *  file_path,
ct_log_level_enum_t  min_level 
)

Add a file output destination for CTaps logs.

Logs will be written to the specified file in addition to stderr. Multiple files can be added, each with their own minimum log level.

Parameters
[in]file_pathPath to the log file (will be created/appended)
[in]min_levelMinimum log level to write to this file
Returns
0 on success, negative error code on failure
Note
The file will be opened in append mode
File handle remains open for the lifetime of the library
This should be called after ct_initialize()

◆ ct_set_log_level()

void ct_set_log_level ( ct_log_level_enum_t  level)

Set the minimum logging level for CTaps.

Only log messages at or above this level will be output. By default, CTaps logs at CT_LOG_INFO level and above.

Parameters
[in]levelMinimum log level (CT_LOG_TRACE through CT_LOG_ERROR)
Note
This can be called before ct_initialize() or at any time during execution
Lower numeric values are more verbose (TRACE=0, ERROR=4)
See also
ct_log_level_enum_t for available log levels