Defines error logging macros.
ErrlogMacros | Defines error logging macros. |
Copyright | This program is free software. |
Files | |
C-kern/ | Header file of ErrlogMacros. |
C-kern/ | Implementation file Errorlog-Writer. |
Functions | |
query | |
GETBUFFER_ERRLOG | See GETBUFFER_LOG. |
COMPARE_ERRLOG | See COMPARE_LOG. |
change | |
CLEARBUFFER_ERRLOG | See CLEARBUFFER_LOG. |
FLUSHBUFFER_LOG | See FLUSHBUFFER_LOG. |
log-text | |
PRINTF_ERRLOG | Logs a generic printf type format string as error. |
PRINTTEXT_ERRLOG | Logs an TEXTID from C-kern/resource/errlog.text. |
PRINTTEXT_USER_ERRLOG | Logs an TEXTID from C-kern/resource/errlog.text to log_channel_USERERR. |
TRACEABORT_ERRLOG | Logs the abortion of a function and the its corresponding error code. |
TRACEABORTFREE_ERRLOG | Logs that an error occurred during free_XXX or delete_XXX. |
TRACECALL_ERRLOG | Logs reason of failure and name of called app function. |
TRACEOUTOFMEM_ERRLOG | Logs “out of memory” reason for function abort. |
TRACESYSCALL_ERRLOG | Logs reason of failure and name of called system function. |
TRACE_ERRLOG | Logs an TEXTID from C-kern/resource/errlog.text and error number err. |
TRACE2_ERRLOG | Logs an TEXTID from C-kern/resource/errlog.text and error number err. |
TRACE_NOARG_ERRLOG | Logs an TEXTID from C-kern/resource/errlog.text and error number err. |
log-variables | |
PRINTARRAYFIELD_ERRLOG | Log value of variable stored in array at offset i. |
PRINTCSTR_ERRLOG | Log “name=value” of string variable. |
PRINTINT_ERRLOG | Log “name=value” of int variable. |
PRINTINT64_ERRLOG | Log “name=value” of int variable. |
PRINTSIZE_ERRLOG | Log “name=value” of size_t variable. |
PRINTUINT8_ERRLOG | Log “name=value” of uint8_t variable. |
PRINTUINT16_ERRLOG | Log “name=value” of uint16_t variable. |
PRINTUINT32_ERRLOG | Log “name=value” of uint32_t variable. |
PRINTUINT64_ERRLOG | Log “name=value” of uint64_t variable. |
PRINTPTR_ERRLOG | Log “name=value” of pointer variable. |
PRINTDOUBLE_ERRLOG | Log “name=value” of double or float variable. |
This program is free software. You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
© 2011 Jörg Seebohn
Header file of ErrlogMacros.
Implementation file Errorlog-Writer.
query | |
GETBUFFER_ERRLOG | See GETBUFFER_LOG. |
COMPARE_ERRLOG | See COMPARE_LOG. |
change | |
CLEARBUFFER_ERRLOG | See CLEARBUFFER_LOG. |
FLUSHBUFFER_LOG | See FLUSHBUFFER_LOG. |
log-text | |
PRINTF_ERRLOG | Logs a generic printf type format string as error. |
PRINTTEXT_ERRLOG | Logs an TEXTID from C-kern/resource/errlog.text. |
PRINTTEXT_USER_ERRLOG | Logs an TEXTID from C-kern/resource/errlog.text to log_channel_USERERR. |
TRACEABORT_ERRLOG | Logs the abortion of a function and the its corresponding error code. |
TRACEABORTFREE_ERRLOG | Logs that an error occurred during free_XXX or delete_XXX. |
TRACECALL_ERRLOG | Logs reason of failure and name of called app function. |
TRACEOUTOFMEM_ERRLOG | Logs “out of memory” reason for function abort. |
TRACESYSCALL_ERRLOG | Logs reason of failure and name of called system function. |
TRACE_ERRLOG | Logs an TEXTID from C-kern/resource/errlog.text and error number err. |
TRACE2_ERRLOG | Logs an TEXTID from C-kern/resource/errlog.text and error number err. |
TRACE_NOARG_ERRLOG | Logs an TEXTID from C-kern/resource/errlog.text and error number err. |
log-variables | |
PRINTARRAYFIELD_ERRLOG | Log value of variable stored in array at offset i. |
PRINTCSTR_ERRLOG | Log “name=value” of string variable. |
PRINTINT_ERRLOG | Log “name=value” of int variable. |
PRINTINT64_ERRLOG | Log “name=value” of int variable. |
PRINTSIZE_ERRLOG | Log “name=value” of size_t variable. |
PRINTUINT8_ERRLOG | Log “name=value” of uint8_t variable. |
PRINTUINT16_ERRLOG | Log “name=value” of uint16_t variable. |
PRINTUINT32_ERRLOG | Log “name=value” of uint32_t variable. |
PRINTUINT64_ERRLOG | Log “name=value” of uint64_t variable. |
PRINTPTR_ERRLOG | Log “name=value” of pointer variable. |
PRINTDOUBLE_ERRLOG | Log “name=value” of double or float variable. |
#define GETBUFFER_ERRLOG( buffer, size ) GETBUFFER_LOG(log_channel_ERR, buffer, size)
See GETBUFFER_LOG.
#define COMPARE_ERRLOG( size, logbuffer ) COMPARE_LOG(log_channel_ERR, size, logbuffer)
See COMPARE_LOG.
#define CLEARBUFFER_ERRLOG( ) CLEARBUFFER_LOG(log_channel_ERR)
See CLEARBUFFER_LOG.
#define FLUSHBUFFER_ERRLOG( ) FLUSHBUFFER_LOG(log_channel_ERR)
See FLUSHBUFFER_LOG.
#define PRINTF_ERRLOG( ... ) PRINTF_LOG(log_channel_ERR, log_flags_NONE, 0, __VA_ARGS__)
Logs a generic printf type format string as error.
FORMAT | The format string as in the standard library function printf. |
... | Additional value parameters of the correct type as determined by the <FORMAT> parameter. |
int i ; PRINTF_ERRLOG("%d", i)
#define PRINTTEXT_USER_ERRLOG( TEXTID, ... ) do { PRINTTEXT_LOG( log_channel_USERERR, log_flags_NONE, 0, TEXTID ## _ERRLOG, __VA_ARGS__) ; } while(0)
Logs an TEXTID from C-kern/resource/errlog.text to log_channel_USERERR. The parameters after TEXTID must match the parameters of the resource TEXTID.
#define TRACEABORT_ERRLOG( err ) TRACE_NOARG_ERRLOG(log_flags_END|log_flags_OPTIONALHEADER, FUNCTION_ABORT, err)
Logs the abortion of a function and the its corresponding error code. If a function encounters an error from which it cannot recover it should roll back the system to its previous state before it was called and use
TRACEABORT_ERRLOG(return_error_code)
to signal this fact.
#define TRACECALL_ERRLOG( fct_name, err ) TRACE_ERRLOG(log_flags_START, FUNCTION_CALL, err, fct_name)
Logs reason of failure and name of called app function. Use this function to log an error in a function which calls a library function which does no logging on its own.
TODO: Support own error IDs
#define TRACEOUTOFMEM_ERRLOG( size, err ) TRACE_ERRLOG(log_flags_START, MEMORY_OUT_OF, err, size)
Logs “out of memory” reason for function abort. If a function could not allocate memory of size bytes and therefore aborts with an error code
TRACEOUTOFMEM_ERRLOG(size_of_memory_in_bytes)
should be called before TRACEABORT_ERRLOG to document the event leading to an abort.
#define TRACE_ERRLOG( FLAGS, TEXTID, err, ... ) TRACE2_ERRLOG(FLAGS, TEXTID, __FUNCTION__, __FILE__, __LINE__, err, __VA_ARGS__)
Logs an TEXTID from C-kern/resource/errlog.text and error number err. Parameter FLAGS carries additional flags to control the logging process - see log_flags_e. Any additional arguments are listed after err. Use TRACE_ERRLOG to log any language specific text with additional parameter values.
#define TRACE2_ERRLOG( FLAGS, TEXTID, funcname, filename, linenr, err, ... ) do { log_header_t _header = log_header_INIT(funcname, filename, linenr, err) ; PRINTTEXT_LOG(log_channel_ERR, FLAGS, &_header, TEXTID ## _ERRLOG, __VA_ARGS__) ; } while(0)
Logs an TEXTID from C-kern/resource/errlog.text and error number err.
FLAGS | Additional flags to control the logging process. See log_flags_e. |
TEXTID | Error text ID from C-kern/resource/errlog.text. |
funcname | Name of function - used to describe error position. |
filename | Name of source file - used to describe error position. |
linenr | Number of current source line - used to describe error position. |
err | Error number. |
... | The following parameter are used to parameterize TEXTID. |
#define TRACE_NOARG_ERRLOG( FLAGS, TEXTID, err ) do { log_header_t _header = log_header_INIT(__FUNCTION__, __FILE__, __LINE__, err) ; PRINTTEXT_NOARG_LOG( log_channel_ERR, FLAGS, &_header, TEXTID ## _ERRLOG) ; } while(0)
Logs an TEXTID from C-kern/resource/errlog.text and error number err. Parameter FLAGS carries additional flags to control the logging process - see log_flags_e. There are no additional arguments. Use TRACE_NOARG_ERRLOG to log any language specific text with no parameter values.
#define PRINTARRAYFIELD_ERRLOG( format, arrname, index ) PRINTARRAYFIELD_LOG(log_channel_ERR, format, arrname, index)
Log value of variable stored in array at offset i. The logged text is “array[i]=value”.
format | Type of the variable as string in printf format. Use “s” for C strings. Use the C99 standard conforming names PRIx64 for hexadecimal output of uint64_t/int64_t ... |
arrname | The name of the array. |
index | The index of the array entry whose value is to be logged. |
This code logs “names[0]=Jo\n” and “names[1]=Jane\n”.
const char * names[] = { "Jo", "Jane" } ; for(int i = 0; i < 2; ++i) { PRINTARRAYFIELD_ERRLOG("s", names, i) ; }
See GETBUFFER_LOG.
#define GETBUFFER_ERRLOG( buffer, size ) GETBUFFER_LOG(log_channel_ERR, buffer, size)
Returns C-string of buffered log and its length.
#define GETBUFFER_LOG( LOGCHANNEL, /*out char ** */buffer, /*out size_t * */size ) log_maincontext().iimpl->getbuffer(log_maincontext().object, LOGCHANNEL, buffer, size)
See COMPARE_LOG.
#define COMPARE_ERRLOG( size, logbuffer ) COMPARE_LOG(log_channel_ERR, size, logbuffer)
Compare logbuffer[size] to buffered log entries.
#define COMPARE_LOG( LOGCHANNEL, /*size_t*/size, /*const char[size]*/logbuffer ) log_maincontext().iimpl->compare(log_maincontext().object, LOGCHANNEL, size, logbuffer)
See CLEARBUFFER_LOG.
#define CLEARBUFFER_ERRLOG( ) CLEARBUFFER_LOG(log_channel_ERR)
Clears log buffer (sets length of logbuffer to 0).
#define CLEARBUFFER_LOG( LOGCHANNEL ) log_maincontext().iimpl->clearbuffer(log_maincontext().object, LOGCHANNEL)
See FLUSHBUFFER_LOG.
#define FLUSHBUFFER_ERRLOG( ) FLUSHBUFFER_LOG(log_channel_ERR)
Logs a generic printf type format string as error.
#define PRINTF_ERRLOG( ... ) PRINTF_LOG(log_channel_ERR, log_flags_NONE, 0, __VA_ARGS__)
Logs an TEXTID from C-kern/resource/errlog.text.
#define PRINTTEXT_ERRLOG( TEXTID, ... ) do { PRINTTEXT_LOG( log_channel_ERR, log_flags_NONE, 0, TEXTID ## _ERRLOG, __VA_ARGS__) ; } while(0)
Logs an TEXTID from C-kern/resource/errlog.text to log_channel_USERERR.
#define PRINTTEXT_USER_ERRLOG( TEXTID, ... ) do { PRINTTEXT_LOG( log_channel_USERERR, log_flags_NONE, 0, TEXTID ## _ERRLOG, __VA_ARGS__) ; } while(0)
Logs the abortion of a function and the its corresponding error code.
#define TRACEABORT_ERRLOG( err ) TRACE_NOARG_ERRLOG(log_flags_END|log_flags_OPTIONALHEADER, FUNCTION_ABORT, err)
Logs that an error occurred during free_XXX or delete_XXX.
#define TRACEABORTFREE_ERRLOG( err ) TRACE_NOARG_ERRLOG(log_flags_END|log_flags_OPTIONALHEADER, FUNCTION_ABORT_FREE, err)
Logs reason of failure and name of called app function.
#define TRACECALL_ERRLOG( fct_name, err ) TRACE_ERRLOG(log_flags_START, FUNCTION_CALL, err, fct_name)
Logs “out of memory” reason for function abort.
#define TRACEOUTOFMEM_ERRLOG( size, err ) TRACE_ERRLOG(log_flags_START, MEMORY_OUT_OF, err, size)
Logs reason of failure and name of called system function.
#define TRACESYSCALL_ERRLOG( sys_fctname, err ) TRACE_ERRLOG(log_flags_START, FUNCTION_SYSCALL, err, sys_fctname)
Logs an TEXTID from C-kern/resource/errlog.text and error number err.
#define TRACE_ERRLOG( FLAGS, TEXTID, err, ... ) TRACE2_ERRLOG(FLAGS, TEXTID, __FUNCTION__, __FILE__, __LINE__, err, __VA_ARGS__)
Logs an TEXTID from C-kern/resource/errlog.text and error number err.
#define TRACE2_ERRLOG( FLAGS, TEXTID, funcname, filename, linenr, err, ... ) do { log_header_t _header = log_header_INIT(funcname, filename, linenr, err) ; PRINTTEXT_LOG(log_channel_ERR, FLAGS, &_header, TEXTID ## _ERRLOG, __VA_ARGS__) ; } while(0)
Logs an TEXTID from C-kern/resource/errlog.text and error number err.
#define TRACE_NOARG_ERRLOG( FLAGS, TEXTID, err ) do { log_header_t _header = log_header_INIT(__FUNCTION__, __FILE__, __LINE__, err) ; PRINTTEXT_NOARG_LOG( log_channel_ERR, FLAGS, &_header, TEXTID ## _ERRLOG) ; } while(0)
Log value of variable stored in array at offset i.
#define PRINTARRAYFIELD_ERRLOG( format, arrname, index ) PRINTARRAYFIELD_LOG(log_channel_ERR, format, arrname, index)
Log “name=value” of string variable.
#define PRINTCSTR_ERRLOG( varname ) PRINTCSTR_LOG(log_channel_ERR, varname)
Log “name=value” of int variable.
#define PRINTINT_ERRLOG( varname ) PRINTINT_LOG(log_channel_ERR, varname)
Log “name=value” of int variable.
#define PRINTINT64_ERRLOG( varname ) PRINTINT64_LOG(log_channel_ERR, varname)
Log “name=value” of size_t variable.
#define PRINTSIZE_ERRLOG( varname ) PRINTSIZE_LOG(log_channel_ERR, varname)
Log “name=value” of uint8_t variable.
#define PRINTUINT8_ERRLOG( varname ) PRINTUINT8_LOG(log_channel_ERR, varname)
Log “name=value” of uint16_t variable.
#define PRINTUINT16_ERRLOG( varname ) PRINTUINT16_LOG(log_channel_ERR, varname)
Log “name=value” of uint32_t variable.
#define PRINTUINT32_ERRLOG( varname ) PRINTUINT32_LOG(log_channel_ERR, varname)
Log “name=value” of uint64_t variable.
#define PRINTUINT64_ERRLOG( varname ) PRINTUINT64_LOG(log_channel_ERR, varname)
Log “name=value” of pointer variable.
#define PRINTPTR_ERRLOG( varname ) PRINTPTR_LOG(log_channel_ERR, varname)
Log “name=value” of double or float variable.
#define PRINTDOUBLE_ERRLOG( varname ) PRINTDOUBLE_LOG(log_channel_ERR, varname)