20#define _XOPEN_SOURCE 500
44static const char*_timestamp(
const char* p_File,
45 const unsigned int p_Line,
46 const char* p_CompilDate,
47 const char* p_CompilTime,
48 const char* p_Function) {
51 static char l_tmp[120];
52 time_t l_CurrentTime = time(NULL);
56 if ((NULL==p_File)|| (0==p_File[0])||
58 (NULL==p_CompilDate)|| (0==p_CompilDate[0])||
59 (NULL==p_CompilTime)|| (0==p_CompilTime[0])||
60 (NULL==p_Function)|| (0==p_Function[0])) {
61 fprintf(stderr,
"%s:%d Unexpected and invalid parameters\n",__FILE__, __LINE__);
65 strftime(l_Time,
sizeof(l_Time),
"%Y-%m-%d %H:%M:%S", localtime(&l_CurrentTime));
69 snprintf(l_tmp,
sizeof(l_tmp),
70 "%19s [%20s:%-4ud] (%11s @ %8s) %30s()",
71 l_Time,p_File,p_Line,p_CompilDate,p_CompilTime,p_Function
78 const unsigned int p_Line,
79 const char* p_CompilDate,
80 const char* p_CompilTime,
const char* p_Function) {
82 fprintf (stderr,
"%s\n",
83 _timestamp( p_File, p_Line, p_CompilDate, p_CompilTime, p_Function)
89 const unsigned int p_Line,
90 const char* p_CompilDate,
91 const char* p_CompilTime,
92 const char* p_Function,
const char* p_Message) {
94 fprintf (stderr,
"%s : %s\n",
95 _timestamp( p_File, p_Line, p_CompilDate, p_CompilTime, p_Function),
102 const unsigned int p_Line,
103 const char* p_CompilDate,
104 const char* p_CompilTime,
105 const char* p_Function,
const char* p_Format, ...
110 unsigned int l_length;
116 va_start(l_ap, p_Format);
118 l_length = vsnprintf(l_tmp,
sizeof(l_tmp),p_Format,l_ap);
122 if (l_length >=
sizeof(l_tmp)-1) {
124 strcpy(&(l_tmp[
sizeof(l_tmp)-6]),
"[...]");
128 fprintf (stderr,
"%s : %s\n",
129 _timestamp( p_File, p_Line, p_CompilDate, p_CompilTime, p_Function),
void _trace_dynmsg(const char *p_File, const unsigned int p_Line, const char *p_CompilDate, const char *p_CompilTime, const char *p_Function, const char *p_Format,...)
Print a debug trace (checkpoint) with a formatted message.
void _trace_msg(const char *p_File, const unsigned int p_Line, const char *p_CompilDate, const char *p_CompilTime, const char *p_Function, const char *p_Message)
Print a debug trace (checkpoint) with a static message.
void _trace(const char *p_File, const unsigned int p_Line, const char *p_CompilDate, const char *p_CompilTime, const char *p_Function)
Print a debug trace (checkpoint)