Log Reference

File
XSFoundation/include/XS/Functions/Log.h
Author
Jean-David Gadina - www.xs-labs.com
Copyright
© (c) 2020 - Jean-David Gadina - www.xs-labs.com
Date
Sunday, September 27, 2020

Overview

Logging functions

Tasks

XSFatalErrorWithInfos

Logs a fatal message to the standard error output and aborts the program

XS_EXPORT void XSFatalErrorWithInfos( const char *file, int line, const char *func, const char *fmt, ... ) XS_NORETURN_ATTRIBUTE;

Discussion

Do not use this function directly. Use the XSFatalError macro instead.

Parameters
  • file
    The file in which the log occurs
  • line
    The line number of the file in which the log occurs
  • func
    The function in which the log occurs
  • fmt
    The format string (printf like)
  • ...
    Arguments for the format

XSGetLogLevel

Gets the log level for XSLog functions/macros

XS_EXPORT int64_t XSGetLogLevel( void );

Return value

The actual log level

See also

XSLogWithInfos

Logs a message to the standard error output

XS_EXPORT void XSLogWithInfos( XSLogLevel level, const char *file, int line, const char *func, const char *fmt, ... );

Discussion

Do not use this function directly. Use the XSLog... macros instead.

Parameters
  • level
    The level of the log message
  • file
    The file in which the log occurs
  • line
    The line number of the file in which the log occurs
  • func
    The function in which the log occurs
  • fmt
    The format string (printf like)
  • ...
    Arguments for the format

XSSetLogLevel

Sets the log level for XSLog functions/macros

XS_EXPORT void XSSetLogLevel( int64_t level );

Parameters
  • level
    The desired log level
See also

XSShow

Logs the description of an object to the console

XS_EXPORT void XSShowWithInfos( XSObjectRef object, const char *file, int line, const char *func );

Discussion

Do not use this function directly. Use the XSShow macro instead.

Parameters
  • object
    The object to log
  • file
    The file in which the log occurs
  • line
    The line number of the file in which the log occurs
  • func
    The function in which the log occurs

XSShowWithInfos

Logs the description of an object to the console

XS_EXPORT void XSShowWithInfos( XSObjectRef object, const char *file, int line, const char *func );

Discussion

Do not use this function directly. Use the XSShow macro instead.

Parameters
  • object
    The object to log
  • file
    The file in which the log occurs
  • line
    The line number of the file in which the log occurs
  • func
    The function in which the log occurs

XSVLogWithInfos

Logs a message to the standard error output

XS_EXPORT void XSVLogWithInfos( XSLogLevel level, const char *file, int line, const char *func, const char *fmt, va_list args );

Discussion

Do not use this function directly. Use the XSVLog... macros instead.

Parameters
  • level
    The level of the log message
  • file
    The file in which the log occurs
  • line
    The line number of the file in which the log occurs
  • func
    The function in which the log occurs
  • fmt
    The format string (printf like)
  • args
    Arguments for the format

Macros

XSFatalError

Issues a fatal error message and aborts the program

#ifdef DEBUG #define XSFatalError( ... ) XSFatalErrorWithInfos( __FILE__, __LINE__, __func__, __VA_ARGS__ ) #else #define XSFatalError( ... ) XSFatalErrorWithInfos( NULL, 0, NULL, __VA_ARGS__ ) #endif

Parameters
  • ...
    The error message with optional format arguments

XSLog

Logs a message (info level) to the standard error output

#ifdef DEBUG #define XSLog( ... ) XSLogWithInfos( XSLogLevelInfo, __FILE__, __LINE__, __func__, __VA_ARGS__ ) #else #define XSLog( ... ) XSLogWithInfos( XSLogLevelInfo, NULL, 0, NULL, __VA_ARGS__ ) #endif

Parameters
  • ...
    The format string (printf like) with optional format arguments for the format

XSLogAlert

Logs a message (alert level) to the standard error output

#ifdef DEBUG #define XSLogAlert( ... ) XSLogWithInfos( XSLogLevelAlert, __FILE__, __LINE__, __func__, __VA_ARGS__ ) #else #define XSLogAlert( ... ) XSLogWithInfos( XSLogLevelAlert, NULL, 0, NULL, __VA_ARGS__ ) #endif

Parameters
  • ...
    The format string (printf like) with optional format arguments for the format

XSLogCritical

Logs a message (critical level) to the standard error output

#ifdef DEBUG #define XSLogCritical( ... ) XSLogWithInfos( XSLogLevelCritical, __FILE__, __LINE__, __func__, __VA_ARGS__ ) #else #define XSLogCritical( ... ) XSLogWithInfos( XSLogLevelCritical, NULL, 0, NULL, __VA_ARGS__ ) #endif

Parameters
  • ...
    The format string (printf like) with optional format arguments for the format

XSLogDebug

Logs a message (debug level) to the standard error output

#ifdef DEBUG #define XSLogDebug( ... ) XSLogWithInfos( XSLogLevelDebug, __FILE__, __LINE__, __func__, __VA_ARGS__ ) #else #define XSLogDebug( ... ) XSLogWithInfos( XSLogLevelDebug, NULL, 0, NULL, __VA_ARGS__ ) #endif

Parameters
  • ...
    The format string (printf like) with optional format arguments for the format

XSLogEmergency

Logs a message (emergency level) to the standard error output

#ifdef DEBUG #define XSLogEmergency( ... ) XSLogWithInfos( XSLogLevelEmergency, __FILE__, __LINE__, __func__, __VA_ARGS__ ) #else #define XSLogEmergency( ... ) XSLogWithInfos( XSLogLevelEmergency, NULL, 0, NULL, __VA_ARGS__ ) #endif

Parameters
  • ...
    The format string (printf like) with optional format arguments for the format

XSLogError

Logs a message (error level) to the standard error output

#ifdef DEBUG #define XSLogError( ... ) XSLogWithInfos( XSLogLevelError, __FILE__, __LINE__, __func__, __VA_ARGS__ ) #else #define XSLogError( ... ) XSLogWithInfos( XSLogLevelError, NULL, 0, NULL, __VA_ARGS__ ) #endif

Parameters
  • ...
    The format string (printf like) with optional format arguments for the format

XSLogInfo

Logs a message (info level) to the standard error output

#ifdef DEBUG #define XSLogInfo( ... ) XSLogWithInfos( XSLogLevelInfo, __FILE__, __LINE__, __func__, __VA_ARGS__ ) #else #define XSLogInfo( ... ) XSLogWithInfos( XSLogLevelInfo, NULL, 0, NULL, __VA_ARGS__ ) #endif

Parameters
  • ...
    The format string (printf like) with optional format arguments for the format

XSLogNotice

Logs a message (notice level) to the standard error output

#ifdef DEBUG #define XSLogNotice( ... ) XSLogWithInfos( XSLogLevelNotice, __FILE__, __LINE__, __func__, __VA_ARGS__ ) #else #define XSLogNotice( ... ) XSLogWithInfos( XSLogLevelNotice, NULL, 0, NULL, __VA_ARGS__ ) #endif

Parameters
  • ...
    The format string (printf like) with optional format arguments for the format

XSLogWarning

Logs a message (warning level) to the standard error output

#ifdef DEBUG #define XSLogWarning( ... ) XSLogWithInfos( XSLogLevelWarning, __FILE__, __LINE__, __func__, __VA_ARGS__ ) #else #define XSLogWarning( ... ) XSLogWithInfos( XSLogLevelWarning, NULL, 0, NULL, __VA_ARGS__ ) #endif

Parameters
  • ...
    The format string (printf like) with optional format arguments for the format

XSShow

Logs the description of an object to the console

#ifdef DEBUG #define XSShow( _obj_ ) XSShowWithInfos( _obj_, __FILE__, __LINE__, __func__ ) #else #define XSShow( _obj_ ) XSShowWithInfos( _obj_, NULL, 0, NULL ) #endif

Parameters
  • _obj_
    The object to log

XSVLog

Logs a message (info level) to the standard error output

#ifdef DEBUG #define XSVLog( _fmt_, _args_ ) XSLogWithInfos( XSLogLevelInfo, __FILE__, __LINE__, __func__, _fmt_, _args_ ) #else #define XSVLog( _fmt_, _args_ ) XSLogWithInfos( XSLogLevelInfo, NULL, 0, NULL, _fmt_, _args_ ) #endif

Parameters
  • _fmt_
    The format string (printf like)
  • _args_
    Arguments for the format (va_list)

XSVLogAlert

Logs a message (alert level) to the standard error output

#ifdef DEBUG #define XSVLogAlert( _fmt_, _args_ ) XSLogWithInfos( XSLogLevelAlert, __FILE__, __LINE__, __func__, _fmt_, _args_ ) #else #define XSVLogAlert( _fmt_, _args_ ) XSLogWithInfos( XSLogLevelAlert, NULL, 0, NULL, _fmt_, _args_ ) #endif

Parameters
  • _fmt_
    The format string (printf like)
  • _args_
    Arguments for the format (va_list)

XSVLogCritical

Logs a message (critical level) to the standard error output

#ifdef DEBUG #define XSVLogCritical( _fmt_, _args_ ) XSLogWithInfos( XSLogLevelCritical, __FILE__, __LINE__, __func__, _fmt_, _args_ ) #else #define XSVLogCritical( _fmt_, _args_ ) XSLogWithInfos( XSLogLevelCritical, NULL, 0, NULL, _fmt_, _args_ ) #endif

Parameters
  • _fmt_
    The format string (printf like)
  • _args_
    Arguments for the format (va_list)

XSVLogDebug

Logs a message (debug level) to the standard error output

#ifdef DEBUG #define XSVLogDebug( _fmt_, _args_ ) XSLogWithInfos( XSLogLevelDebug, __FILE__, __LINE__, __func__, _fmt_, _args_ ) #else #define XSVLogDebug( _fmt_, _args_ ) XSLogWithInfos( XSLogLevelDebug, NULL, 0, NULL, _fmt_, _args_ ) #endif

Parameters
  • _fmt_
    The format string (printf like)
  • _args_
    Arguments for the format (va_list)

XSVLogEmergency

Logs a message (emergency level) to the standard error output

#ifdef DEBUG #define XSVLogEmergency( _fmt_, _args_ ) XSLogWithInfos( XSLogLevelEmergency, __FILE__, __LINE__, __func__, _fmt_, _args_ ) #else #define XSVLogEmergency( _fmt_, _args_ ) XSLogWithInfos( XSLogLevelEmergency, NULL, 0, NULL, _fmt_, _args_ ) #endif

Parameters
  • _fmt_
    The format string (printf like)
  • _args_
    Arguments for the format (va_list)

XSVLogError

Logs a message (error level) to the standard error output

#ifdef DEBUG #define XSVLogError( _fmt_, _args_ ) XSLogWithInfos( XSLogLevelError, __FILE__, __LINE__, __func__, _fmt_, _args_ ) #else #define XSVLogError( _fmt_, _args_ ) XSLogWithInfos( XSLogLevelError, NULL, 0, NULL, _fmt_, _args_ ) #endif

Parameters
  • _fmt_
    The format string (printf like)
  • _args_
    Arguments for the format (va_list)

XSVLogInfo

Logs a message (info level) to the standard error output

#ifdef DEBUG #define XSVLogInfo( _fmt_, _args_ ) XSLogWithInfos( XSLogLevelInfo, __FILE__, __LINE__, __func__, _fmt_, _args_ ) #else #define XSVLogInfo( _fmt_, _args_ ) XSLogWithInfos( XSLogLevelInfo, NULL, 0, NULL, _fmt_, _args_ ) #endif

Parameters
  • _fmt_
    The format string (printf like)
  • _args_
    Arguments for the format (va_list)

XSVLogNotice

Logs a message (notice level) to the standard error output

#ifdef DEBUG #define XSVLogNotice( _fmt_, _args_ ) XSLogWithInfos( XSLogLevelNotice, __FILE__, __LINE__, __func__, _fmt_, _args_ ) #else #define XSVLogNotice( _fmt_, _args_ ) XSLogWithInfos( XSLogLevelNotice, NULL, 0, NULL, _fmt_, _args_ ) #endif

Parameters
  • _fmt_
    The format string (printf like)
  • _args_
    Arguments for the format (va_list)

XSVLogWarning

Logs a message (warning level) to the standard error output

#ifdef DEBUG #define XSVLogWarning( _fmt_, _args_ ) XSLogWithInfos( XSLogLevelWarning, __FILE__, __LINE__, __func__, _fmt_, _args_ ) #else #define XSVLogWarning( _fmt_, _args_ ) XSLogWithInfos( XSLogLevelWarning, NULL, 0, NULL, _fmt_, _args_ ) #endif

Parameters
  • _fmt_
    The format string (printf like)
  • _args_
    Arguments for the format (va_list)