aboutsummaryrefslogtreecommitdiff
path: root/src/trace.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2007-12-12 17:06:16 +0000
committerMike Buland <eichlan@xagasoft.com>2007-12-12 17:06:16 +0000
commit7eb00b6d3037a7e30c326b43e23502f777b92eb6 (patch)
tree60013b086b3682c68192ad2ac8337e221ec9eba9 /src/trace.cpp
parentba4167f75c8f7ba8726132eed94af3ae6cd38eee (diff)
downloadlibbu++-7eb00b6d3037a7e30c326b43e23502f777b92eb6.tar.gz
libbu++-7eb00b6d3037a7e30c326b43e23502f777b92eb6.tar.bz2
libbu++-7eb00b6d3037a7e30c326b43e23502f777b92eb6.tar.xz
libbu++-7eb00b6d3037a7e30c326b43e23502f777b92eb6.zip
Corrected some issues with the new trace system. It's now working fine. It's backword compatible, and the new features are a lot of fun. Since it uses template functions you can add any new variable types to be formatted.
Diffstat (limited to '')
-rw-r--r--src/trace.cpp116
1 files changed, 116 insertions, 0 deletions
diff --git a/src/trace.cpp b/src/trace.cpp
new file mode 100644
index 0000000..b328565
--- /dev/null
+++ b/src/trace.cpp
@@ -0,0 +1,116 @@
1#define BU_TRACE
2#include "bu/trace.h"
3
4void Bu::__tracer( const char *pf )
5{
6 printf("trace: %s\n", pf );
7}
8
9template<> void Bu::__tracer_format<int8_t>( const int8_t &v )
10{
11 printf("%hhd", v );
12}
13
14template<> void Bu::__tracer_format<uint8_t>( const uint8_t &v )
15{
16 printf("%hhu", v );
17}
18
19template<> void Bu::__tracer_format<int16_t>( const int16_t &v )
20{
21 printf("%hd", v );
22}
23
24template<> void Bu::__tracer_format<uint16_t>( const uint16_t &v )
25{
26 printf("%hu", v );
27}
28
29template<> void Bu::__tracer_format<int32_t>( const int32_t &v )
30{
31 printf("%d", v );
32}
33
34template<> void Bu::__tracer_format<uint32_t>( const uint32_t &v )
35{
36 printf("%u", v );
37}
38
39template<> void Bu::__tracer_format<int64_t>( const int64_t &v )
40{
41 printf("%lld", v );
42}
43
44template<> void Bu::__tracer_format<uint64_t>( const uint64_t &v )
45{
46 printf("%llu", v );
47}
48
49template<> void Bu::__tracer_format<bool>( const bool &v )
50{
51 if( v )
52 printf("true");
53 else
54 printf("false");
55}
56
57template<> void Bu::__tracer_format<char>( const char &v )
58{
59 printf("%hhd", v );
60}
61
62template<> void Bu::__tracer_format<long>( const long &v )
63{
64 printf("%ld", v );
65}
66
67template<> void Bu::__tracer_format<unsigned long>( const unsigned long &v )
68{
69 printf("%lu", v );
70}
71
72template<> void Bu::__tracer_format<float>( const float &v )
73{
74 printf("%f", v );
75}
76
77template<> void Bu::__tracer_format<double>( const double &v )
78{
79 printf("%f", v );
80}
81
82template<> void Bu::__tracer_format<void *>( void * const &v )
83{
84 printf("0x%08X", (unsigned int)v );
85}
86
87template<> void Bu::__tracer_format<char *>( char * const &v )
88{
89 printf("\"%s\"", v );
90}
91
92template<> void Bu::__tracer_format<char **>( char ** const &v )
93{
94 printf("[");
95 for( int j = 0; v[j]; j++ )
96 printf("\"%s\"", v[j] );
97 printf("]");
98}
99
100template<> void Bu::__tracer_format<void const *>( void const * const &v )
101{
102 printf("0x%08X", (unsigned int)v );
103}
104
105template<> void Bu::__tracer_format<char const *>( char const * const &v )
106{
107 printf("\"%s\"", v );
108}
109
110template<> void Bu::__tracer_format<char const **>( char const ** const &v )
111{
112 printf("[");
113 for( int j = 0; v[j]; j++ )
114 printf("\"%s\"", v[j] );
115 printf("]");
116}