das2C
das core C utilities (v3)
Macros | Typedefs | Functions
Utilities

Library initialization, error handling, logging and a few minor libc extensions. More...

Macros

#define DAS_OKAY   0
 success return code
 
#define daslog_trace(M)   daslog(DASLOG_TRACE, __FILE__, __LINE__, M)
 Macro wrapper around das_log() for TRACE messages with out variable args.
 
#define daslog_debug(M)   daslog(DASLOG_DEBUG, __FILE__, __LINE__, M)
 Macro wrapper around das_log() for DEBUG messages with out variable args.
 
#define daslog_info(M)   daslog(DASLOG_INFO, __FILE__, __LINE__, M)
 Macro wrapper around das_log() for INFO messages with out variable args.
 
#define daslog_warn(M)   daslog(DASLOG_WARN, __FILE__, __LINE__, M)
 Macro wrapper around das_log() for WARNING messages with out variable args.
 
#define daslog_error(M)   daslog(DASLOG_ERROR, __FILE__, __LINE__, M)
 Macro wrapper around das_log() for ERROR messages with out variable args.
 
#define daslog_critical(M)   daslog(DAS_LL_CRITICAL, __FILE__, __LINE__, M)
 Macro wrapper around das_log() for CRITICAL messages with out variable args.
 
#define daslog_trace_v(F, ...)    daslog(DASLOG_TRACE, __FILE__, __LINE__, F, __VA_ARGS__)
 Macro wrapper around das_log() for TRACE messages with variable arguments.
 
#define daslog_debug_v(F, ...)    daslog(DASLOG_DEBUG, __FILE__, __LINE__, F, __VA_ARGS__)
 Macro wrapper around das_log() for DEBUG messages with variable arguments.
 
#define daslog_info_v(F, ...)    daslog(DASLOG_INFO, __FILE__, __LINE__, F, __VA_ARGS__)
 Macro wrapper around das_log() for INFO messages with variable arguments.
 
#define daslog_warn_v(F, ...)    daslog(DASLOG_WARN, __FILE__, __LINE__, F, __VA_ARGS__)
 Macro wrapper around das_log() for WARNING messages with variable arguments.
 
#define daslog_error_v(F, ...)    daslog(DASLOG_ERROR, __FILE__, __LINE__, F, __VA_ARGS__)
 Macro wrapper around das_log() for ERROR messages with variable arguments.
 
#define daslog_critical_v(F, ...)    daslog(DASLOG_CRIT, __FILE__, __LINE__, F, __VA_ARGS__)
 Macro wrapper around das_log() for CRITICAL messages with variable arguments.
 

Typedefs

typedef int DasErrCode
 return code type 0 indicates success, negative integer indicates failure
 

Functions

DAS_API int daslog_level (void)
 Get the log level. More...
 
DAS_API int daslog_setlevel (int nLevel)
 Set the logging level for this thread. More...
 
DAS_API int daslog_strlevel (const char *sLevel)
 Get a logging level integer from a string. More...
 
DAS_API bool daslog_set_showline (int nLevel)
 Output source file and line numbers for messages at or above this level.
 
DAS_API das_log_handler_t daslog_sethandler (das_log_handler_t new_handler)
 Install a new message handler function for this thread. More...
 

Detailed Description

Library initialization, error handling, logging and a few minor libc extensions.

Function Documentation

◆ daslog_level()

DAS_API int daslog_level ( void  )

Get the log level.

Returns
one of: DASLOG_CRIT, DASLOG_ERROR, DASLOG_WARN, DASLOG_INFO, DASLOG_DEBUG, DASLOG_TRACE

◆ daslog_setlevel()

DAS_API int daslog_setlevel ( int  nLevel)

Set the logging level for this thread.

Parameters
nLevelSet to one of
  • DASLOG_TRACE
  • DASLOG_DEBUG
  • DASLOG_NOTICE
  • DASLOG_WARN
  • DASLOG_ERROR
  • DASLOG_CRITICAL
  • DASLOG_NOTHING
Returns
The previous log level.

◆ daslog_strlevel()

DAS_API int daslog_strlevel ( const char *  sLevel)

Get a logging level integer from a string.

This function may safely be called prior to das_init()

Parameters
sLevelOne of "crit", "err", "warn", "info", "debug", "trace". Case is not signifiant, extra letters after the first are actually ignored.
Returns
One of DASLOG_CRIT, DASLOG_ERROR, DASLOG_WARN, DASLOG_INFO, DASLOG_DEBUG, DASLOG_TRACE, if the string is understood, DASLOG_NOTHING if not.

◆ daslog_sethandler()

DAS_API das_log_handler_t daslog_sethandler ( das_log_handler_t  new_handler)

Install a new message handler function for this thread.

The default message handler just prints to stderr, which is not very effecient, nor is it appropriate for GUI applications.

Parameters
new_handlerThe new message handler, or NULL to set to the default handler.
Returns
The previous message handler function pointer