bio
 
Loading...
Searching...
No Matches
bio_log_options_t Struct Reference

Logging options. More...

#include <bio.h>

Data Fields

const char * current_filename
 Full path to the file that is calling bio_init.
 
int current_depth_in_project
 The depth of the calling file in your project tree.
 

Detailed Description

Logging options.

Typically, it would be used like this:

.log_options = {
.current_filename = __FILE__,
.current_depth_in_project = 1, // If the file is in src/main.c
},
});
void bio_init(const bio_options_t *options)
Initialize the framework.
Initialization options.
Definition bio.h:408

This helps the logging system to shorten the paths in log messages. The logging macros use the preprocessor variables __FILE__ and __LINE__ to give more context to each message. However, __FILE__ would typically expands into an absolute path (e.g: /home/username/projects/project_name/src/file.c). This gives the log messages an extremely long and superflous prefix:

[INFO ][/home/username/projects/project_name/src/file.c:41]: Log message

By passing these info to the log system, the above message will be just:

[INFO ][src/file.c:41]: Log message

The bio_log_ctx_t::file passed to each logger will be the shortened version.

When this option is not provided, filename shortening will not be performed.

Take note that if you have source files out of the project tree (e.g: /home/username/projects/another_project_name), filename shortening will not be performed either and the full path will be logged. It is recommended to keep dependencies in the source tree (e.g: /home/username/projects/project_name/deps). In that case, any logging calls from dependencies will show up as deps/dependency_name.

Field Documentation

◆ current_depth_in_project

int bio_log_options_t::current_depth_in_project

The depth of the calling file in your project tree.

If the file that is calling bio_init is src/main.c for example, this should be 1.

◆ current_filename

const char* bio_log_options_t::current_filename

Full path to the file that is calling bio_init.


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