TreeFrogFramework: src/tsystemglobal.h Source File

1#pragma once

2#include <QMap>

3#include <QSettings>

4#include <QVariant>

5#include <TGlobal>

6

7class TSystemLogger;

8class TAccessLog;

9class QSqlError;

10

11namespace Tf {

23

24#ifdef TF_HAVE_STD_FORMAT

25

26template<typename... Args>

27void traceQueryLog(int duration, const std::format_string<Args...> &fmt, Args&&... args)

28{

29 auto msg = std::format(fmt, std::forward<Args>(args)...);

30 traceQuery(duration, QByteArray::fromStdString(msg));

31}

32

33#else

34

35template<typename... Args>

36void traceQueryLog(int duration, const std::string &fmt, Args&&... args)

37{

38 auto msg = Tf::simple_format(std::string(fmt), std::forward<Args>(args)...);

40}

41

42#endif

43

52

53T_CORE_EXPORT QMap<QString, QVariant> settingsToMap(QSettings &settings, const QString &env = QString());

54}

55

56#ifdef TF_HAVE_STD_FORMAT

57

58template<typename... Args>

59void tSystemError(const std::format_string<Args...> &fmt, Args&&... args)

60{

61 std::string msg = std::format(fmt, std::forward<Args>(args)...);

63}

64

65template<typename... Args>

66void tSystemWarn(const std::format_string<Args...> &fmt, Args&&... args)

67{

68 std::string msg = std::format(fmt, std::forward<Args>(args)...);

70}

71

72template<typename... Args>

73void tSystemInfo(const std::format_string<Args...> &fmt, Args&&... args)

74{

75 auto msg = std::format(fmt, std::forward<Args>(args)...);

77}

78

79#else

80

81template<typename... Args>

82void tSystemError(const std::string &fmt, Args&&... args)

83{

84 auto msg = Tf::simple_format(std::string(fmt), std::forward<Args>(args)...);

86}

87

88template<typename... Args>

89void tSystemWarn(const std::string &fmt, Args&&... args)

90{

91 auto msg = Tf::simple_format(std::string(fmt), std::forward<Args>(args)...);

93}

94

95template<typename... Args>

96void tSystemInfo(const std::string &fmt, Args&&... args)

97{

98 auto msg = Tf::simple_format(std::string(fmt), std::forward<Args>(args)...);

100}

101

102#endif

103

104#ifndef TF_NO_DEBUG

105#ifdef TF_HAVE_STD_FORMAT

106

107template<typename... Args>

108void tSystemDebug(const std::format_string<Args...> &fmt, Args&&... args)

109{

110 auto msg = std::format(fmt, std::forward<Args>(args)...);

112}

113

114template<typename... Args>

115void tSystemTrace(const std::format_string<Args...> &fmt, Args&&... args)

116{

117 auto msg = std::format(fmt, std::forward<Args>(args)...);

119}

120

121#else

122

123template<typename... Args>

124void tSystemDebug(const std::string &fmt, Args&&... args)

125{

126 auto msg = Tf::simple_format(std::string(fmt), std::forward<Args>(args)...);

128}

129

130template<typename... Args>

131void tSystemTrace(const std::string &fmt, Args&&... args)

132{

133 auto msg = Tf::simple_format(std::string(fmt), std::forward<Args>(args)...);

135}

136

137#endif

138#else

139

140template<typename... Args>

142{}

143

144template<typename... Args>

146{}

147

148#endif

The Tf namespace contains miscellaneous identifiers used throughout the library of TreeFrog Framework...

Definition tdebug.h:10

T_CORE_EXPORT void releaseSystemLogger()

Definition tsystemglobal.cpp:78

T_CORE_EXPORT void tSystemMessage(int priority, const QByteArray &message)

Definition tsystemglobal.cpp:37

void error(const std::format_string< Args... > &fmt, Args &&... args)

Outputs the error message to the log file, formatting args according to the format string fmt.

Definition tglobal.h:248

T_CORE_EXPORT void setupSystemLogger(TSystemLogger *logger=nullptr)

Definition tsystemglobal.cpp:57

T_CORE_EXPORT QMap< QString, QVariant > settingsToMap(QSettings &settings, const QString &env=QString())

Definition tsystemglobal.cpp:161

void traceQueryLog(int duration, const std::format_string< Args... > &fmt, Args &&... args)

Definition tsystemglobal.h:27

T_CORE_EXPORT void writeAccessLog(const TAccessLog &log)

Definition tsystemglobal.cpp:49

SystemOpCode

Definition tsystemglobal.h:44

@ WebSocketSendBinary

Definition tsystemglobal.h:47

@ WebSocketPublishText

Definition tsystemglobal.h:48

@ WebSocketPublishBinary

Definition tsystemglobal.h:49

@ WebSocketSendText

Definition tsystemglobal.h:46

@ InvalidOpCode

Definition tsystemglobal.h:45

@ MaxOpCode

Definition tsystemglobal.h:50

@ TraceLevel

Finer-grained informational events than the DEBUG.

Definition tfnamespace.h:236

@ WarnLevel

Potentially harmful situations.

Definition tfnamespace.h:233

@ DebugLevel

Informational events that are most useful to debug the app.

Definition tfnamespace.h:235

@ InfoLevel

Informational messages that highlight the progress of the app.

Definition tfnamespace.h:234

@ ErrorLevel

Error events that might still allow the app to continue running.

Definition tfnamespace.h:232

T_CORE_EXPORT void writeQueryLog(const QString &query, bool success, const QSqlError &error, int duration)

Definition tsystemglobal.cpp:144

T_CORE_EXPORT void releaseQueryLogger()

Definition tsystemglobal.cpp:127

T_CORE_EXPORT void releaseAccessLogger()

Definition tsystemglobal.cpp:101

T_CORE_EXPORT void traceQuery(int duration, const QByteArray &msg)

Definition tsystemglobal.cpp:134

T_CORE_EXPORT void setupAccessLogger()

Definition tsystemglobal.cpp:88

T_CORE_EXPORT bool isAccessLoggerAvailable()

Definition tsystemglobal.cpp:108

T_CORE_EXPORT void setupQueryLogger()

Definition tsystemglobal.cpp:114

#define T_CORE_EXPORT

Definition tdeclexport.h:28

void tSystemTrace(const std::format_string< Args... > &fmt, Args &&... args)

Definition tsystemglobal.h:115

void tSystemInfo(const std::format_string< Args... > &fmt, Args &&... args)

Definition tsystemglobal.h:73

void tSystemDebug(const std::format_string< Args... > &fmt, Args &&... args)

Definition tsystemglobal.h:108

void tSystemError(const std::format_string< Args... > &fmt, Args &&... args)

Definition tsystemglobal.h:59

void tSystemWarn(const std::format_string< Args... > &fmt, Args &&... args)

Definition tsystemglobal.h:66