clogger  Version 2.1.1
API Reference for clogger
clogger.h File Reference

File for use with the CLogger structure. More...

Macros

#define CLOGGER_FILE_OPT_OFF_BITS   0x0
 
#define CLOGGER_FILE_OPT_PREPEND_BIT   0x1
 
#define CLOGGER_FILE_OPT_INFO_BIT   0x2
 
#define CLOGGER_FILE_OPT_DEBUG_BIT   0x4
 
#define CLOGGER_FILE_OPT_WARNING_BIT   0x8
 
#define CLOGGER_FILE_OPT_ERROR_BIT   0x10
 
#define CLOGGER_FILE_OPT_CRITICAL_BIT   0x20
 
#define CLOGGER_FILE_OPT_ASSERT_BIT   0x40
 
#define CLOGGER_FILE_OPT_EXPECT_BIT   0x80
 
#define CLOGGER_FILE_OPT_DEFAULT_BITS   0x30
 

Enumerations

enum  CLoggerFileOpt {
  CLOGGER_FILE_OPT_OFF = CLOGGER_FILE_OPT_OFF_BITS, CLOGGER_FILE_OPT_PREPEND, CLOGGER_FILE_OPT_INFO, CLOGGER_FILE_OPT_DEBUG,
  CLOGGER_FILE_OPT_WARNING, CLOGGER_FILE_OPT_ERROR, CLOGGER_FILE_OPT_CRITICAL, CLOGGER_FILE_OPT_ASSERT,
  CLOGGER_FILE_OPT_EXPECT, CLOGGER_FILE_OPT_DEFAULT = CLOGGER_FILE_OPT_DEFAULT_BITS
}
 Enumeration of bit flags for CLogger::file_opt. More...
 

Functions

void clogger_init (CLogger *logger, const char *clogger_name)
 Creates a logger instance. More...
 
void clogger_init_filepath (CLogger *logger, const char *clogger_name, const char *file_path)
 Creates a logger instance with a specific filepath. More...
 
void clogger_set_error_callback (CLogger *logger, void(*callback)(CLoggerLevel level, const char *clogger_name, const char *location))
 Sets error callback function. More...
 
void clogger_set_assert_fail_callback (CLogger *logger, void(*callback)())
 Sets callback function for assert fail. More...
 
void clogger_info (CLogger *logger, const char *location, const char *message,...)
 CLOG_LEVEL_INFO log message, will only call if the CLogger struct is set as such More...
 
void clogger_debug (CLogger *logger, const char *location, const char *message,...)
 CLOG_LEVEL_DEBUG log message, will only call if the CLogger struct is set as such More...
 
void clogger_warning (CLogger *logger, const char *location, const char *message,...)
 CLOG_LEVEL_WARNING log message, will only call if the CLogger struct is set as such More...
 
void clogger_error (CLogger *logger, const char *location, const char *message,...)
 CLOG_LEVEL_ERROR log message, will only call if the CLogger struct is set as such More...
 
void clogger_critical (CLogger *logger, const char *location, const char *message,...)
 CLOG_LEVEL_CRITICAL log message, will only call if the CLogger struct is set as such More...
 
void clogger_assert (CLogger *logger, CLoggerBool condition, const char *location, const char *message,...)
 CLOG_LEVEL_FATAL_ASSERT log message, will only call if the condition fails More...
 
CLoggerBool clogger_expect (CLogger *logger, CLoggerBool condition, const char *location, const char *message,...)
 CLOG_LEVEL_NON_FATAL_ASSERT log message, will only call if the condition fails More...
 
void clogger_set_file_opt_option (CLogger *logger, CLoggerFileOpt option, CLoggerBool enabled)
 Set the CLogger::file_opt More...
 

Detailed Description

File for use with the CLogger structure.

Enumeration Type Documentation

◆ CLoggerFileOpt

Enumeration of bit flags for CLogger::file_opt.

Enumerator
CLOGGER_FILE_OPT_OFF 

Turns off all CLogger::file_opt bits.

CLOGGER_FILE_OPT_PREPEND 

Determines whether the CLogger should append or prepend to file.

CLOGGER_FILE_OPT_INFO 

Determines whether the CLogger should log INFO messages to file.

CLOGGER_FILE_OPT_DEBUG 

Determines whether the CLogger should log DEBUG messages to file.

CLOGGER_FILE_OPT_WARNING 

Determines whether the CLogger should log WARNING messages to file.

CLOGGER_FILE_OPT_ERROR 

Determines whether the CLogger should log ERROR messages to file.

CLOGGER_FILE_OPT_CRITICAL 

Determines whether the CLogger should log CRITICAL messages to file.

CLOGGER_FILE_OPT_ASSERT 

Determines whether the CLogger should log ASSERT messages to file.

CLOGGER_FILE_OPT_EXPECT 

Determines whether the CLogger should log EXPECT messages to file.

CLOGGER_FILE_OPT_DEFAULT 

Default CLogger::file_opt

Function Documentation

◆ clogger_init()

void clogger_init ( CLogger logger,
const char *  clogger_name 
)

Creates a logger instance.

Parameters
logger[in, out] Pointer to CLogger to initialise
clogger_name[in] Name of the logger

◆ clogger_init_filepath()

void clogger_init_filepath ( CLogger logger,
const char *  clogger_name,
const char *  file_path 
)

Creates a logger instance with a specific filepath.

Parameters
logger[in, out] Pointer to CLogger to initialise
clogger_name[in] Name of the logger
file_path[in] File path to initialise CLogger with

◆ clogger_set_error_callback()

void clogger_set_error_callback ( CLogger logger,
void(*)(CLoggerLevel level, const char *clogger_name, const char *location)  callback 
)

Sets error callback function.

Parameters
logger[in, out] Pointer to CLogger data structure
callback[in] Callback function to set

◆ clogger_set_assert_fail_callback()

void clogger_set_assert_fail_callback ( CLogger logger,
void(*)()  callback 
)

Sets callback function for assert fail.

Parameters
logger[in, out] Pointer to CLogger data structure
callback[in] Callback function to set

◆ clogger_info()

void clogger_info ( CLogger logger,
const char *  location,
const char *  message,
  ... 
)

CLOG_LEVEL_INFO log message, will only call if the CLogger struct is set as such

Parameters
logger[in] Pointer to CLogger data structure
location[in] Location of the log
message[in] Format-able string message as you would use printf()
...[in] Variable-length args

◆ clogger_debug()

void clogger_debug ( CLogger logger,
const char *  location,
const char *  message,
  ... 
)

CLOG_LEVEL_DEBUG log message, will only call if the CLogger struct is set as such

Parameters
logger[in] Pointer to CLogger data structure
location[in] Location of the log
message[in] Format-able string message as you would use printf()
...[in] Variable-length args

◆ clogger_warning()

void clogger_warning ( CLogger logger,
const char *  location,
const char *  message,
  ... 
)

CLOG_LEVEL_WARNING log message, will only call if the CLogger struct is set as such

Parameters
logger[in] Pointer to CLogger data structure
location[in] Location of the log
message[in] Format-able string message as you would use printf()
...[in] Variable-length args

◆ clogger_error()

void clogger_error ( CLogger logger,
const char *  location,
const char *  message,
  ... 
)

CLOG_LEVEL_ERROR log message, will only call if the CLogger struct is set as such

Parameters
logger[in] Pointer to CLogger data structure
location[in] Location of the log
message[in] Format-able string message as you would use printf()
...[in] Variable-length args

◆ clogger_critical()

void clogger_critical ( CLogger logger,
const char *  location,
const char *  message,
  ... 
)

CLOG_LEVEL_CRITICAL log message, will only call if the CLogger struct is set as such

Parameters
logger[in] Pointer to CLogger data structure
location[in] Location of the log
message[in] Format-able string message as you would use printf()
...[in] Variable-length args

◆ clogger_assert()

void clogger_assert ( CLogger logger,
CLoggerBool  condition,
const char *  location,
const char *  message,
  ... 
)

CLOG_LEVEL_FATAL_ASSERT log message, will only call if the condition fails

If the condition fails, the function pointed to in CLogger::assert_fail will be invoked. By default, this is the exit() function.

Parameters
logger[in] Pointer to CLogger data structure
condition[in] Condition to evaluate
location[in] Location of the log
message[in] Format-able string message as you would use printf()
...[in] Variable-length args

◆ clogger_expect()

CLoggerBool clogger_expect ( CLogger logger,
CLoggerBool  condition,
const char *  location,
const char *  message,
  ... 
)

CLOG_LEVEL_NON_FATAL_ASSERT log message, will only call if the condition fails

Parameters
logger[in] Pointer to CLogger data structure
condition[in] Condition to evaluate
location[in] Location of the log
message[in] Format-able string message as you would use printf()
...[in] Variable-length args
Returns
Evaluated condition

◆ clogger_set_file_opt_option()

void clogger_set_file_opt_option ( CLogger logger,
CLoggerFileOpt  option,
CLoggerBool  enabled 
)

Set the CLogger::file_opt

Parameters
loggerPointer to the CLogger to set the option for
optionFlags
enabledEnable or disable