11 #ifndef __UT_ErrorLog__
12 #define __UT_ErrorLog__
52 virtual bool filterError(
int level,
54 const char *prefix) = 0;
57 static void registerCallback(ErrorCallback *err);
68 {
return myLogFileName; }
72 myLogFileName.harden(name);
73 myLogFileName.expandVariables();
78 {
return myMinLevel; }
83 myMinConsoleLevel =
level;
86 {
return myMinConsoleLevel; }
90 myMinConsoleLevel =
level;
94 {
return myDoLogging; }
100 {
return myLogToConsole; }
104 myLogToConsole =
log;
107 {
return myForceConsoleColor; }
111 myForceConsoleColor =
log; }
113 {
return myLogToSystem; }
133 myAppendDate = append_date;
139 myErrorLogTimes.clear();
151 myHeaderCallback = callback;
155 typedef int (*MantraVerboseCallback)();
156 typedef int (*MantraColorCallback)();
157 typedef bool (*MantraTimestampCallback)();
164 static void setMantraVerboseLevel(
int level);
165 static int getMantraVerboseLevel();
166 static bool isMantraVerbose(
int level);
167 static void setMantraElapsedTime(
bool enable);
168 static bool mantraElapsedTime();
172 static void setMantraVerboseCallback(MantraVerboseCallback cb);
173 static void setMantraColorCallback(MantraColorCallback cb);
174 static void setMantraTimestampCallback(MantraTimestampCallback cb);
176 static int mantraPrintf(
int level,
const char *msg, ...)
178 static
int mantraWarning(const
char *msg, ...)
180 static
int mantraError(const
char *msg, ...)
181 SYS_PRINTF_CHECK_ATTRIBUTE(1,2);
185 template <typename... Args>
186 static
size_t format(
int lev, const
char *fmt, const Args &...
args)
188 if (!isMantraVerbose(lev))
192 return mantraPrintf(lev,
"%s", buf.
buffer());
194 template <
typename... Args>
197 if (!isMantraVerbose(1))
201 return mantraWarning(
"%s", buf.
buffer());
203 template <
typename... Args>
204 static size_t error(
const char *fmt,
const Args &...
args)
208 return mantraError(
"%s", buf.
buffer());
211 template <
typename... Args>
215 if (!isMantraVerbose(lev))
219 return mantraPrintfOnce(lev,
"%s", buf.
buffer());
221 template <
typename... Args>
224 if (!isMantraVerbose(1))
228 return mantraWarningOnce(
"%s", buf.
buffer());
230 template <
typename... Args>
235 return mantraErrorOnce(
"%s", buf.
buffer());
240 static int mantraPrintfOnce(
int level,
const char *msg, ...)
242 static
int mantraWarningOnce(const
char *msg, ...)
244 static
int mantraErrorOnce(const
char *msg, ...)
245 SYS_PRINTF_CHECK_ATTRIBUTE(1,2);
249 static
void clearMantraOnceErrors();
251 static
void printErrorToConsole(const
char *msg,
252 const
char *prefix = "",
253 bool enable_color = false);
254 static
void printWarningToConsole(const
char *msg,
255 const
char *prefix = "",
256 bool enable_color = false);
257 static
void printMessageToConsole(const
char *msg,
258 const
char *prefix = "",
259 bool enable_color = false);
264 int myMinConsoleLevel;
269 bool myForceConsoleColor;
273 HeaderCallback myHeaderCallback;
276 time_t myLastErrorTime;
GLuint GLsizei const GLchar * message
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
GLenum GLuint GLenum GLsizei const GLchar * buf
void setMinLevel(const int level)
void setForceConsoleColor(bool log)
void setLogToConsole(bool log)
SYS_FORCE_INLINE const char * buffer() const
UT_API UT_ErrorLog * UTgetErrorLog()
static size_t error(const char *fmt, const Args &...args)
void setLogToSystem(bool log)
void setDoLogging(bool log)
static size_t formatOnce(int lev, const char *fmt, const Args &...args)
void setAppendDate(bool append_date)
int getMinConsoleLevel() const
static size_t warningOnce(const char *fmt, const Args &...args)
const UT_String & getLogFileName() const
void setLogFileName(const UT_String &name)
static size_t warning(const char *fmt, const Args &...args)
static size_t errorOnce(const char *fmt, const Args &...args)
#define SYS_PRINTF_CHECK_ATTRIBUTE(string_index, first_to_check)
GLint GLint GLsizei GLint GLenum format
void setMaxLogSize(int64 size)
bool getAppendDate() const
void setPrefix(const UT_StringHolder &prefix)
GLuint const GLchar * name
std::function< T > UT_Function
bool getLogToConsole() const
size_t format(const char *fmt, const Args &...args)
LeafData & operator=(const LeafData &)=delete
bool getForceConsoleColor() const
void setHeaderCallback(HeaderCallback callback)
const UT_StringHolder & getPrefix() const
bool getLogToSystem() const
**If you just want to fire and args
void setMinConsoleLevel(const int level)
Functor to handle errors printed out using the mantra* methods.
OIIO_FORCEINLINE T log(const T &v)
bool getDoLogging() const
UT_Function< void(UT_WorkBuffer &)> HeaderCallback