acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
trace_statement.h
1// From tracer.h by camilo on 2023-06-10 23:27 <3ThomasBorregaardSorensen!!
2#pragma once
3
4
5//#include "acme/prototype/prototype/pointer.h"
6#include "acme/filesystem/file/string_stream.h"
7#if defined(__STD_FORMAT)
8#include <format>
9#endif
10
11class particle;
12
13constexpr ::particle * trace_this() { return nullptr; }
14
15
16struct trace_statement_struct
17{
18
19 ::platform::tracer * m_ptracer;
20 ::particle * m_pparticleLogging = nullptr;
21 enum_trace_level m_etracelevel = e_trace_level_information;
22 enum_trace_category m_etracecategory = e_trace_category_general;
23 const_char_pointer m_pszFunction = nullptr;
24 const_char_pointer m_pszFile = nullptr;
25 ::i32 m_iLine = -1;
26
27 trace_statement_struct(::platform::tracer * ptracer) : m_ptracer(ptracer) {}
28 trace_statement_struct(trace_statement_struct && tracestatementstruct) = default;
29
30};
31
32
33class CLASS_DECL_ACME trace_statement :
34 virtual public string_stream,
35 virtual public trace_statement_struct
36{
37public:
38
39
40 trace_statement(::platform::tracer * ptracer);
41 trace_statement(const trace_statement & tracestatement) = delete;
42 trace_statement(trace_statement && tracestatement) :
43 trace_statement_struct(::transfer(tracestatement)),
44 string_stream(::transfer(tracestatement)),
45 write_text_stream(::transfer(tracestatement)),
46 write_text_stream_struct(::transfer(tracestatement))
47 {
48 tracestatement.m_ptracer = nullptr;
49 }
50 ~trace_statement();
51
52
53 //template < typename T >
54 //inline auto & operator << (T && t){ return (*m_ptracer) << t; }
55
56 inline trace_statement & operator()(::particle * pparticle) { m_pparticleLogging = pparticle; return *this; }
57 inline trace_statement & operator()(enum_trace_level etracelevel) { m_etracelevel = etracelevel; return *this; }
58 inline trace_statement & operator()(enum_trace_category etracecategory) { m_etracecategory = etracecategory; return *this; }
59 inline trace_statement & operator()(const_char_pointer pszFunction, const_char_pointer pszFile, ::i32 iLine)
60 {
61 m_pszFunction = pszFunction;
62 m_pszFile = pszFile;
63 m_iLine = iLine;
64 return *this;
65 }
66
67
68 void formatf_output_arguments(const_char_pointer psz, va_list & arguments);
69
71
72 template<typename... Args>
73 void format_output(std::format_string<Args...> fmt, Args&&... args)
74 {
75
76 string str;
77
78 str.format(fmt, ::std::forward < Args >(args)...);
79
80 operator << (str);
81
82 }
83
84 //trace_statement & operator()(const_char_pointer pszFormat, ...);
85
86 template<typename... Args>
87 trace_statement & operator()(std::format_string<Args...> fmt, Args&&... args)
88 {
89
90 return format_output(fmt, ::std::forward < Args >(args)...);
91
92 }
93 //#endif
94
95
96 ::string prefix() const;
97
98
99 //void format_output_arguments(const_char_pointer psz, va_list & arguments)
100//{
101
102// string str;
103
104// str.formatf_arguments(scopedstr, arguments);
105
106// operator << (str);
107
108//}
109
110
111//tracer & format_output(const_char_pointer psz, ...)
112//{
113
114// va_list arguments;
115
116// va_start(arguments, psz);
117
118// string str;
119
120// str.formatf_arguments(scopedstr, arguments);
121
122// operator << (str);
123
124// va_end(arguments);
125
126// return *this;
127
128//}
129
130
131//template < typename STRINGABLE >
132//tracer & operator <<(const STRINGABLE & stringable)
133//{
134
135// string str;
136
137// ::copy(str, stringable);
138
139// m_str += str;
140
141// return *this;
142
143// //return operator << (str);
144
145//}
146
147};
148
149
150
151
152
153
154CLASS_DECL_ACME::trace_statement log_statement();
155//CLASS_DECL_ACME trace_statement trace_log_warning() << ;
156//CLASS_DECL_ACME trace_statement trace_log_error() << ;
157//CLASS_DECL_ACME trace_statement trace_log_fatal() << ;
158
159
160
Definition particle.h:95
Definition tracer.h:19
Definition trace_statement.h:36
void format_output(std::format_string< Args... > fmt, Args &&... args)
if defined(STD_FORMAT)
Definition trace_statement.h:73