![]() |
Tesseroids 1.0: User Manual and API Documentation |
Functions to set up logging. More...
#include <stdio.h>
Go to the source code of this file.
Data Structures | |
struct | LOGGER |
Keep the information on the global logger. More... | |
Defines | |
#define | LOG_DEBUG 0 |
Logging level for debug messages. | |
#define | LOG_INFO 1 |
Logging level for general information. | |
#define | LOG_WARNING 2 |
Logging level for warning messages. | |
#define | LOG_ERROR 3 |
Logging level for error messages. | |
Functions | |
void | log_init (int level) |
Setup logging to stderr. | |
void | log_tofile (FILE *logfile, int level) |
Set logging to a file. | |
void | log_debug (const char *fmt,...) |
Log a message at debug level. | |
void | log_info (const char *fmt,...) |
Log a message at info level. | |
void | log_warning (const char *fmt,...) |
Log a message at warning level. | |
void | log_error (const char *fmt,...) |
Log a message at error level. | |
Variables | |
LOGGER | logger |
Global logger struct. |
Functions to set up logging.
Example:
#include "logger.h" void my_func(){ log_info("From my_func!\n"); } int main(){ log_init(LOG_DEBUG); log_debug("debug line. The code is %d", LOG_DEBUG); log_info("info line. The code is %d", LOG_INFO); log_warning("warning line. The code is %d", LOG_WARNING); log_error("error line. The code is %d", LOG_ERROR); return 0; }
Will print:
DEBUG: debug line. The code is 0 info line. The code is 1 WARNING: warning line. The code is 2 ERROR: error line. The code is 3
If function log_init() is not called than logging is disabled and no messages will be printed to stderr.
void log_debug | ( | const char * | fmt, | |
... | ||||
) |
Log a message at debug level.
Pass parameters in the same format as printf()
Prints a newline at the end.
void log_error | ( | const char * | fmt, | |
... | ||||
) |
Log a message at error level.
Pass parameters in the same format as printf()
Prints a newline at the end.
void log_info | ( | const char * | fmt, | |
... | ||||
) |
Log a message at info level.
Pass parameters in the same format as printf()
Does not print "INFO: " in front of the message when logging
Prints a newline at the end.
void log_init | ( | int | level | ) |
Setup logging to stderr.
level | level of logging to be made. Can be one of:
|
void log_tofile | ( | FILE * | logfile, | |
int | level | |||
) |
Set logging to a file.
logfile | FILE pointer to the already open file to log to. | |
level | level of logging to be made to the file. Can be one of:
|
void log_warning | ( | const char * | fmt, | |
... | ||||
) |
Log a message at warning level.
Pass parameters in the same format as printf()
Prints a newline at the end.