-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.cpp
More file actions
85 lines (65 loc) · 2.09 KB
/
debug.cpp
File metadata and controls
85 lines (65 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/******************************************************************************
* @file debug.cpp
*
* @brief
*
* @date 24-11-2010
* @author Rafal Kukla
******************************************************************************
* Copyright (C) 2010 Rafal Kukla ( rkdevel@gmail.com )
* This file is a part of rs232testng project and is released
* under the terms of the license contained in the file LICENSE
******************************************************************************
*/
#include <cstring>
#include <ctime>
#include <cstdio>
#include <cstdarg>
#include "debug.h"
int dbglevel = DBGLVL_ALL;
//#include <Windows.h>
void outf(const char* fmt, ...)
{
va_list arglist;
va_start(arglist,fmt);
outv(fmt,arglist);
va_end(arglist);
}
void _outdbgmsgf(int level, const char* source, const char* msg,...)
{
va_list arglist;
char lvlprn[16];
const char *lvlname;
//static HANDLE mtx = CreateMutex(NULL,FALSE,NULL);
// WaitForSingleObject(mtx,INFINITE);
#if defined(OUTDBGMSG_INCLUDE_TIMESTAMP) && (OUTDBGMSG_INCLUDE_TIMESTAMP >0 )
clock_t t = clock();
fprintf(DBGOUT, "%10d: ", t);
#endif
#if defined(OUTDBGMSG_INCLUDE_SOURCE) && (OUTDBGMSG_INCLUDE_SOURCE >0 )
fprintf(DBGOUT, "%-16.16s: ", source);
#endif
#if defined(OUTDBGMSG_INCLUDE_LEVEL) && (OUTDBGMSG_INCLUDE_LEVEL >0 )
switch(level)
{
case DBGMSG_ERROR : lvlname = "[ERR]"; break;
case DBGMSG_WARNING : lvlname = "[WRN]"; break;
case DBGMSG_INFO : lvlname = "[INF]"; break;
case DBGMSG_DEBUG : lvlname = "[DBG]"; break;
case DBGMSG_TRACE : lvlname = "[TRC]"; break;
default:
_snprintf(lvlprn,LENOF(lvlprn)-1,"[%d]",level);
lvlprn[LENOF(lvlprn)-1] = 0;
lvlname = lvlprn;
}
fprintf(DBGOUT, "%-5s: ", lvlname);
#endif
va_start(arglist,msg);
vfprintf(DBGOUT,msg,arglist);
va_end(arglist);
//ReleaseMutex(mtx);
}
void _outdbgmsg(int level, const char* source, const char* msg)
{
_outdbgmsgf(level, source, "%s",msg);
}