1 /*******************************************************************************
2 
3         copyright:      Copyright (c) 2007 Kris Bell. All rights reserved
4 
5         license:        BSD style: $(LICENSE)
6 
7         version:        Oct 2007: Initial release
8 
9         author:         Kris
10 
11         Synchronized, formatted console output. Usage is:
12         ---
13         Trace.formatln ("hello {}", "world");
14         ---
15 
16         Note that this has become merely a wrapper around Log.formatln(), so
17         please use that API instead
18 
19 *******************************************************************************/
20 
21 module tango.util.log.Trace;
22 
23 public import tango.util.log.Config;
24 
25 /*******************************************************************************
26 
27         redirect to the Log module
28 
29 *******************************************************************************/
30 
31 public alias Log Trace;
32 
33 /*******************************************************************************
34 
35 *******************************************************************************/
36 
37 debug (Trace)
38 {
39         void main()
40         {
41                 Trace.formatln ("hello {}", "world");
42                 Trace ("hello {}", "world");
43         }
44 }
45 
46 
47 
48 
49 
50 
51 
52 
53 
54 
55 
56 
57 
58 /+
59         /**********************************************************************
60 
61                 Print a range of raw memory as a hex dump.
62                 Characters in range 0x20..0x7E are printed, all others are
63                 shown as dots.
64 
65                 ----
66 000000:  47 49 46 38  39 61 10 00  10 00 80 00  00 48 5D 8C  GIF89a.......H].
67 000010:  FF FF FF 21  F9 04 01 00  00 01 00 2C  00 00 00 00  ...!.......,....
68 000020:  10 00 10 00  00 02 11 8C  8F A9 CB ED  0F A3 84 C0  ................
69 000030:  D4 70 A7 DE  BC FB 8F 14  00 3B                     .p.......;
70                 ----
71 
72         **********************************************************************/
73 
74         final void memory (void[] mem)
75         {
76             auto data = cast(ubyte[]) mem;
77             synchronized (mutex)
78             {
79                 for( int row = 0; row < data.length; row += 16 )
80                 {
81                     // print relative offset
82                     convert.convert (&sink, "{:X6}:  ", row );
83 
84                     // print data bytes
85                     for( int idx = 0; idx < 16 ; idx++ )
86                     {
87                         // print byte or stuffing spaces
88                         if ( idx + row < data.length )
89                             convert (&sink, "{:X2} ", data[ row + idx ] );
90                         else
91                             output.write ("   ");
92 
93                         // after each 4 bytes group an extra space
94                         if (( idx & 0x03 ) == 3 )
95                             output.write (" ");
96                     }
97 
98                     // ascii view
99                     // all char 0x20..0x7e are OK for printing,
100                     // other values are printed as a dot
101                     ubyte[16] ascii = void;
102                     int asciiIdx;
103                     for ( asciiIdx = 0;
104                         (asciiIdx<16) && (asciiIdx+row < data.length);
105                         asciiIdx++ )
106                     {
107                         ubyte c = data[ row + asciiIdx ];
108                         if ( c < 0x20 || c > 0x7E )
109                             c = '.';
110                         ascii[asciiIdx] = c;
111                     }
112                     output.write (ascii[ 0 .. asciiIdx ]);
113                     output.write (Eol);
114                 }
115                 if (flushLines)
116                     output.flush;
117             }
118         }
119 +/
120