Line data Source code
1 : // This file (TLOG_manipulators.cc) was created by Ron Rechenmacher <ron@fnal.gov> on
2 : // Jul 18, 2019. "TERMS AND CONDITIONS" governing this file are in the README
3 : // or COPYING file. If you do not have such a file, one can be obtained by
4 : // contacting Ron or Fermi Lab in Batavia IL, 60510, phone: 630-840-3000.
5 : // $RCSfile: TLOG_manipulators.cc,v $
6 : // rev="$Revision: 1784 $$Date: 2026-10-09 13:51:46 -0500 (Fri, 09 Oct 2026) $";
7 : /*
8 : rm -fr Linux*; \
9 : make OUT=$PWD\
10 : XTRA_CFLAGS='-std=c11 -O0'\
11 : XTRA_CXXFLAGS='-std=c++11 -O0 -DTRACE_STREAMER_MSGMAX=45' 32ON64=1\
12 : src_utility src_example_user script modules 2>&1|tee make.out|egrep -iB4 'error|warn'
13 :
14 : export TRACE_SHOW=%H%n\ %m; treset; tmodeS 0; toffMg 3-63;\
15 : TLOG_manipulators; Linux+3.10-2.17/bin/TLOG_manipulators; \
16 : trace_cntl show; Linux+3.10-2.17/bin/trace_cntl show
17 :
18 : export TRACE_SHOW=%H%n\ %f; treset; tmodeS 0; toffMg 3-63;\
19 : TLOG_manipulators; Linux+3.10-2.17/bin/TLOG_manipulators; \
20 : trace_cntl show; Linux+3.10-2.17/bin/trace_cntl show
21 :
22 : TRACE_SHOW=%f Linux+3.10-2.17/bin/trace_cntl show | while read ln;do echo "$ln" | wc -c;done
23 : */
24 : //#define TRACE_STREAMER_DEBUG 1
25 : #include "TRACE/trace.h"
26 :
27 : #include <stdio.h> // printf
28 0 : int main(int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__)))
29 : {
30 0 : for (unsigned ii= 0; ii < 2; ++ii)
31 0 : TLOG(TLVL_DEBUG) << "ii+10=" << ii + 10 << " " << std::fixed << std::setprecision(1) << 123.456;
32 0 : for (unsigned ii= 0; ii < 2; ++ii) {
33 0 : TLOG(TLVL_DEBUG) << "ii+10=" << ii + 10 << std::hex << " " << ii + 10 << " " << 789.012 << " " << std::setprecision(1)
34 0 : << 123.456;
35 0 : TLOG(TLVL_TRACE) << "ii+10=" << ii + 10 << std::hex << " " << ii + 10 << " " << 789.012 << " " << std::setprecision(2)
36 0 : << 123.456;
37 : }
38 0 : const unsigned char two= 2;
39 0 : const int thr= 3;
40 0 : const short fou= 4;
41 0 : const long fiv= 5;
42 0 : const short unsigned six= 6;
43 0 : const unsigned sev= 7;
44 0 : const long unsigned eig= 8;
45 0 : const long long unsigned nin= 9;
46 0 : const double ten= 10;
47 0 : const float ele= 11;
48 0 : const bool twe= 12;
49 : #if defined(__cplusplus) && (__cplusplus >= 201103L)
50 0 : const std::atomic<int> tht(13);
51 0 : std::atomic<unsigned long> const fot(14);
52 0 : std::atomic<short int> const fit(15);
53 0 : std::atomic<bool> const sit(16);
54 0 : std::unique_ptr<int> const sEt(new int(17));
55 : #endif
56 0 : void *const eit((void *)18);
57 0 : const char *space= " ";
58 0 : TLOG(2) << '1' << " " << two << " " << thr << " " << fou << " " << fiv << " " << six << " " << sev << " " << eig << " " << nin
59 0 : << " " << ten << " " << ele;
60 0 : for (unsigned ii= 0; ii < strlen(space); ii+= (ii + 1))
61 0 : TLOG(2) << ten << " " << ele << " " << twe << &space[strlen(space) - 1 - ii]
62 : #if defined(__cplusplus) && (__cplusplus >= 201103L)
63 0 : << tht << " " << fot << " " << fit << " " << sit << " " << sEt << " "
64 : #endif
65 0 : << (void *)0x12345 << " " << eit << " " << 99;
66 0 : TLOG() << (void *)0x12345678 << " " << eit << " sizeof(trace_ptr_t)=" << sizeof(trace_ptr_t) << " " << (long double)3.0 << " "
67 0 : << 3 << " " << reinterpret_cast<const void *>(0x1234) << " " << reinterpret_cast<const void *>(0x5678) << " "
68 0 : << reinterpret_cast<long *>(0x1234) << " " << reinterpret_cast<long *>(0x5678);
69 0 : std::cout << std::endl;
70 :
71 0 : std::cout << std::setw(4) << std::showbase << std::setfill('0') << std::hex << 0xf << "\n";
72 0 : std::cout << std::showbase << std::setw(4) << std::setfill('0') << std::hex << 0xf << "\n" << std::noshowbase;
73 0 : std::cout << "0x" << std::setw(4) << std::setfill('0') << std::hex << 0xf << "\n";
74 0 : TLOG() << std::showbase << std::setw(4) << std::setfill('0') << std::hex << 0xf; // manipulator auto reset
75 0 : TLOG() << std::setw(4) << std::showbase << std::setfill('0') << std::hex << 0xf; // manipulator auto reset
76 0 : TLOG() << "0x" << std::setw(4) << std::setfill('0') << std::hex << 0xf; // manipulator auto reset
77 0 : std::cout << std::endl;
78 :
79 0 : std::cout << std::setw(2) << std::showbase << std::setfill('0') << std::hex << 0xf << "\n";
80 0 : std::cout << std::showbase << std::setw(2) << std::setfill('0') << std::hex << 0xf << "\n" << std::noshowbase;
81 0 : std::cout << "0x" << std::setw(2) << std::setfill('0') << std::hex << 0xf << "\n" << std::setfill(' ');
82 0 : TLOG() << std::showbase << std::setw(2) << std::setfill('0') << std::hex << 0xf; // manipulator auto reset
83 0 : TLOG() << std::setw(2) << std::showbase << std::setfill('0') << std::hex << 0xf; // manipulator auto reset
84 0 : TLOG() << "0x" << std::setw(2) << std::setfill('0') << std::hex << 0xf; // manipulator auto reset
85 0 : std::cout << std::endl;
86 :
87 0 : std::cout << std::setw(2) << std::showbase << std::hex << 0xf << "\n";
88 0 : std::cout << std::showbase << std::setw(2) << std::hex << 0xf << "\n" << std::noshowbase;
89 0 : std::cout << "0x" << std::setw(2) << std::hex << 0xf << "\n";
90 0 : TLOG() << std::showbase << std::setw(2) << std::hex << 0xf; // manipulator auto reset
91 0 : TLOG() << std::setw(2) << std::showbase << std::hex << 0xf; // manipulator auto reset
92 0 : TLOG() << "0x" << std::setw(2) << std::hex << 0xf; // manipulator auto reset
93 0 : return (0);
94 0 : } // main
|