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

Standard log functions. More...

Macros

#define CLOGGER_TRACE()   clog_trace(__FUNCTION__, __FILE__, __LINE__)
 Shorthand macro for clog_trace
 
#define CLOGGER_TRACE_LINE(line)   clog_trace(__FUNCTION__, __FILE__, line)
 Shorthand macto for clog_trace, allowing line specification.
 

Functions

CLoggerInt32 clog_messagef (CLoggerLevel level, CLogger *logger, const char *location, const char *format, va_list args)
 The utility log function used throughout the library. More...
 
void clog_message (const char *location, const char *message,...)
 The generic logging message. More...
 
void clog_info (const char *location, const char *message,...)
 Log a message representing a CLOGGER_LEVEL_INFO level message. More...
 
void clog_debug (const char *location, const char *message,...)
 Log a message representing a CLOGGER_LEVEL_DEBUG level message. More...
 
void clog_warning (const char *location, const char *message,...)
 Log a message representing a CLOGGER_LEVEL_WARNING level message. More...
 
void clog_error (const char *location, const char *message,...)
 Log a message representing a CLOGGER_LEVEL_ERROR level message. More...
 
void clog_critical (const char *location, const char *message,...)
 Log a message representing a CLOGGER_LEVEL_CRITICAL level message. More...
 
CLoggerBool clog_append_to_file (const char *file_path, const char *location, const char *message,...)
 Log message to file. More...
 
CLoggerBool clog_prepend_to_file (const char *file_path, const char *location, const char *message,...)
 Prepend log message to file. More...
 
void clog_trace (const char *function_name, const char *file_name, int line)
 Displays a function traceback message. More...
 

Detailed Description

Standard log functions.

Function Documentation

◆ clog_messagef()

CLoggerInt32 clog_messagef ( CLoggerLevel  level,
CLogger logger,
const char *  location,
const char *  format,
va_list  args 
)

The utility log function used throughout the library.

Note
This function isn't typically used by the end user, it's advisable to use the standard functions
Parameters
level[in] The log level
logger[in] Pointer to a CLogger data structure. Pass NULL if not used
location[in] Location of the log, usually __FUNCTION__ though can be NULL
format[in] String detailing the format
args[in] Variable arguments list to use with the format string
Returns
Number of characters written to the console

◆ clog_message()

void clog_message ( const char *  location,
const char *  message,
  ... 
)

The generic logging message.

Parameters
location[in] Location of the log, usually __FUNCTION__ though can be NULL
message[in] Format-able string message as you would use printf()
...[in] Variable-length args for the message string

◆ clog_info()

void clog_info ( const char *  location,
const char *  message,
  ... 
)

Log a message representing a CLOGGER_LEVEL_INFO level message.

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

◆ clog_debug()

void clog_debug ( const char *  location,
const char *  message,
  ... 
)

Log a message representing a CLOGGER_LEVEL_DEBUG level message.

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

◆ clog_warning()

void clog_warning ( const char *  location,
const char *  message,
  ... 
)

Log a message representing a CLOGGER_LEVEL_WARNING level message.

Parameters
location[in] Location of the log,
message[in] Format-able string message as you would use printf()
...[in] Variable-length args

◆ clog_error()

void clog_error ( const char *  location,
const char *  message,
  ... 
)

Log a message representing a CLOGGER_LEVEL_ERROR level message.

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

◆ clog_critical()

void clog_critical ( const char *  location,
const char *  message,
  ... 
)

Log a message representing a CLOGGER_LEVEL_CRITICAL level message.

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

◆ clog_append_to_file()

CLoggerBool clog_append_to_file ( const char *  file_path,
const char *  location,
const char *  message,
  ... 
)

Log message to file.

Parameters
file_path[in] The file path to dump the log message.
Warning
This should be the path to the actual file e.g. /logs/log.txt
Parameters
location[in] Location of the log
message[in] Format-able string message as you would use printf()
...[in] Variable-length args
Returns
CLOGGER_FALSE on failure or CLOGGER_TRUE on success

◆ clog_prepend_to_file()

CLoggerBool clog_prepend_to_file ( const char *  file_path,
const char *  location,
const char *  message,
  ... 
)

Prepend log message to file.

Parameters
file_path[in] The file path to dump the log message.
Warning
This should be the path to the actual file e.g. /logs/log.txt
Parameters
location[in] Location of the log
message[in] Format-able string message as you would use printf()
...[in] Variable-length args
Returns
CLOGGER_FALSE on failure or CLOGGER_TRUE on success

◆ clog_trace()

void clog_trace ( const char *  function_name,
const char *  file_name,
int  line 
)

Displays a function traceback message.

This should be used in sync with the error/critical functions to make debugging/tracing easier as they will not trace back themselves.

Parameters
function_name[in] Name of the function, usually __FUNCTION__
file_name[in] Name of the file, usually __FILE__
line[in] The line number, usually __LINE__ (or some variant)
Remarks
In some IDEs, the traceback message printed to the console/terminal is clickable, allowing the end-user to jump to the point of interest.