@@ -165,14 +165,6 @@ constexpr auto TF_SRC_REVISION = 3082;
165165#define T_VARIANT (VAR ) (variant(QLatin1String(#VAR )).toString())
166166
167167
168- #define tFatal TDebug (Tf::FatalLevel).fatal
169- #define tError TDebug (Tf::ErrorLevel).error
170- #define tWarn TDebug (Tf::WarnLevel).warn
171- #define tInfo TDebug (Tf::InfoLevel).info
172- #define tDebug TDebug (Tf::DebugLevel).debug
173- #define tTrace TDebug (Tf::TraceLevel).trace
174-
175-
176168#include " tfexception.h"
177169#include " tfnamespace.h"
178170#include " tdeclexport.h"
@@ -181,6 +173,86 @@ constexpr auto TF_SRC_REVISION = 3082;
181173#include < cstring>
182174#include < functional>
183175#include < algorithm>
176+
177+
178+ T_CORE_EXPORT bool getAbortOnFatalFlag ();
179+
180+
181+ inline TDebug tFatal ()
182+ {
183+ return TDebug (Tf::FatalLevel);
184+ }
185+
186+ inline TDebug tError ()
187+ {
188+ return TDebug (Tf::ErrorLevel);
189+ }
190+
191+ inline TDebug tWarn ()
192+ {
193+ return TDebug (Tf::WarnLevel);
194+ }
195+
196+ inline TDebug tInfo ()
197+ {
198+ return TDebug (Tf::InfoLevel);
199+ }
200+
201+ inline TDebug tDebug ()
202+ {
203+ return TDebug (Tf::DebugLevel);
204+ }
205+
206+ inline TDebug tTrace ()
207+ {
208+ return TDebug (Tf::TraceLevel);
209+ }
210+
211+ template <typename ... Args>
212+ inline void tFatal (const char *fmt, Args&&... args)
213+ {
214+ TDebug (Tf::FatalLevel).fatal (fmt, std::forward<Args>(args)...);
215+
216+ if (getAbortOnFatalFlag ()) {
217+ #if defined(Q_OS_UNIX)
218+ abort (); // trap; generates core dump
219+ #else
220+ std::exit (-1 );
221+ #endif
222+ }
223+ }
224+
225+ template <typename ... Args>
226+ inline void tError (const char *fmt, Args&&... args)
227+ {
228+ TDebug (Tf::FatalLevel).error (fmt, std::forward<Args>(args)...);
229+ }
230+
231+ template <typename ... Args>
232+ inline void tWarn (const char *fmt, Args&&... args)
233+ {
234+ TDebug (Tf::FatalLevel).warn (fmt, std::forward<Args>(args)...);
235+ }
236+
237+ template <typename ... Args>
238+ inline void tInfo (const char *fmt, Args&&... args)
239+ {
240+ TDebug (Tf::FatalLevel).info (fmt, std::forward<Args>(args)...);
241+ }
242+
243+ template <typename ... Args>
244+ inline void tDebug (const char *fmt, Args&&... args)
245+ {
246+ TDebug (Tf::FatalLevel).debug (fmt, std::forward<Args>(args)...);
247+ }
248+
249+ template <typename ... Args>
250+ inline void tTrace (const char *fmt, Args&&... args)
251+ {
252+ TDebug (Tf::FatalLevel).trace (fmt, std::forward<Args>(args)...);
253+ }
254+
255+
184256#ifdef TF_HAVE_STD_FORMAT // std::format
185257#include < format>
186258
@@ -219,6 +291,7 @@ class TCache;
219291class QSqlDatabase ;
220292
221293namespace Tf {
294+
222295T_CORE_EXPORT TWebApplication *app () noexcept ;
223296T_CORE_EXPORT TAppSettings *appSettings () noexcept ;
224297T_CORE_EXPORT const QVariantMap &conf (const QString &configName) noexcept ;
@@ -262,6 +335,14 @@ void fatal(const std::format_string<Args...> &fmt, Args&&... args)
262335{
263336 std::string msg = std::format (fmt, std::forward<Args>(args)...);
264337 Tf::logging (Tf::FatalLevel, QByteArray::fromStdString (msg));
338+
339+ if (getAbortOnFatalFlag ()) {
340+ #if defined(Q_OS_UNIX)
341+ abort (); // trap; generates core dump
342+ #else
343+ std::exit (-1 );
344+ #endif
345+ }
265346}
266347
267348/* !
@@ -375,6 +456,14 @@ void fatal(const std::string &fmt, Args&&... args)
375456{
376457 auto msg = simple_format (std::string (fmt), std::forward<Args>(args)...);
377458 Tf::logging (Tf::FatalLevel, msg);
459+
460+ if (getAbortOnFatalFlag ()) {
461+ #if defined(Q_OS_UNIX)
462+ abort (); // trap; generates core dump
463+ #else
464+ std::exit (-1 );
465+ #endif
466+ }
378467}
379468
380469template <typename ... Args>
0 commit comments