if((notif.nent_stringcount + notif.nent_floatcount) > count)
{
+ string s =
+ #ifdef NOTIFICATIONS_DEBUG
+ Get_Notif_BroadcastName(broadcast);
+ #else
+ ftos(broadcast);
+ #endif
backtrace(sprintf(
strcat(
"Not enough arguments for Send_Notification(%s, ...)! ",
"Check the definition and function call for accuracy...?\n"
),
sprintf(
- #ifdef NOTIFICATIONS_DEBUG
"%s, '%s', %s, %s",
- Get_Notif_BroadcastName(broadcast),
- #else
- "%d, '%s', %s, %s",
- broadcast,
- #endif
+ s,
client.classname,
Get_Notif_TypeName(net_type),
notif.nent_name
}
else if((notif.nent_stringcount + notif.nent_floatcount) < count)
{
+ string s =
+ #ifdef NOTIFICATIONS_DEBUG
+ Get_Notif_BroadcastName(broadcast);
+ #else
+ ftos(broadcast);
+ #endif
backtrace(sprintf(
strcat(
"Too many arguments for Send_Notification(%s, ...)! ",
"Check the definition and function call for accuracy...?\n"
),
sprintf(
- #ifdef NOTIFICATIONS_DEBUG
"%s, '%s', %s, %s",
- Get_Notif_BroadcastName(broadcast),
- #else
- "%d, '%s', %s, %s",
- broadcast,
- #endif
+ s,
client.classname,
Get_Notif_TypeName(net_type),
notif.nent_name
}
#endif
-// todo: this sucks, lets find a better way to do backtraces?
-void backtrace(string msg)
-{
- float dev, war;
- #ifdef SVQC
- dev = autocvar_developer;
- war = autocvar_prvm_backtraceforwarnings;
- #else
- dev = cvar("developer");
- war = cvar("prvm_backtraceforwarnings");
- #endif
- cvar_set("developer", "1");
- cvar_set("prvm_backtraceforwarnings", "1");
- print("\n");
- print("--- CUT HERE ---\nWARNING: ");
- print(msg);
- print("\n");
- remove(world); // isn't there any better way to cause a backtrace?
- print("\n--- CUT UNTIL HERE ---\n");
- cvar_set("developer", ftos(dev));
- cvar_set("prvm_backtraceforwarnings", ftos(war));
-}
-
// color code replace, place inside of sprintf and parse the string
string CCR(string input)
{
#define XPD(...) __VA_ARGS__
// Some common varargs functions. Lowercase as they match C.
-#define printf(...) print(sprintf(__VA_ARGS__))
-#define dprintf(...) dprint(sprintf(__VA_ARGS__))
#define fprintf(file, ...) fputs(file, sprintf(__VA_ARGS__))
#define bprintf(...) bprint(sprintf(__VA_ARGS__))
-//#ifndef MENUQC
-void backtrace(string msg);
-//#endif
-
// color code replace, place inside of sprintf and parse the string... defaults described as constants
// foreground/normal colors
string autocvar_hud_colorset_foreground_1 = "2"; // F1 - Green // primary priority (important names, etc)
--- /dev/null
+#ifndef LOG_H
+#define LOG_H
+
+#define _printferr(...) error(sprintf(__VA_ARGS__))
+#define _printfbt(...) backtrace(sprintf(__VA_ARGS__))
+#define printf(...) print(sprintf(__VA_ARGS__))
+#define dprintf(...) dprint(sprintf(__VA_ARGS__))
+#define _dprintf2(...) do { if (autocvar_developer > 1) dprintf(__VA_ARGS__); } while (0)
+
+#define _LOG(f, level, s) f("[::"level"] ["__FILE__":%s:%.0f] %s", __FUNC__, __LINE__, s)
+
+#define LOG_FATAL(...) _LOG_FATAL(strcat("", __VA_ARGS__))
+#define LOG_FATALF(...) _LOG_FATAL(sprintf(__VA_ARGS__))
+#define _LOG_FATAL(s) _LOG(_printferr, "FATAL", s)
+
+#define LOG_SEVERE(...) _LOG_SEVERE(strcat("", __VA_ARGS__))
+#define LOG_SEVEREF(...) _LOG_SEVERE(sprintf(__VA_ARGS__))
+#define _LOG_SEVERE(s) _LOG(_printfbt, "SEVERE", s)
+
+#define LOG_WARNING(...) _LOG_WARNING(strcat("", __VA_ARGS__))
+#define LOG_WARNINGF(...) _LOG_WARNING(sprintf(__VA_ARGS__))
+#define _LOG_WARNING(s) _LOG(printf, "WARNING", s)
+
+#define LOG_INFO(...) do { if (autocvar_developer) _LOG_INFO(strcat("", __VA_ARGS__)); else print (__VA_ARGS__); } while (0)
+#define LOG_INFOF(...) do { if (autocvar_developer) _LOG_INFO(sprintf(__VA_ARGS__)); else printf(__VA_ARGS__); } while (0)
+#define _LOG_INFO(s) _LOG(printf, "INFO", s)
+
+#define LOG_TRACE(...) _LOG_TRACE(strcat("", __VA_ARGS__))
+#define LOG_TRACEF(...) _LOG_TRACE(sprintf(__VA_ARGS__))
+#define _LOG_TRACE(s) _LOG(dprintf, "TRACE", s)
+
+#define LOG_DEBUG(...) _LOG_DEBUG(strcat("", __VA_ARGS__))
+#define LOG_DEBUGF(...) _LOG_DEBUG(sprintf(__VA_ARGS__))
+#define _LOG_DEBUG(s) _LOG(_dprintf2, "DEBUG", s)
+
+// TODO: this sucks, lets find a better way to do backtraces?
+#ifdef SVQC
+void builtin_remove(entity);
+#define _backtrace() builtin_remove(NULL)
+#else
+void remove(entity);
+#define _backtrace() remove(NULL)
+#endif
+
+noref int autocvar_developer;
+noref bool autocvar_prvm_backtraceforwarnings;
+
+#define backtrace(msg) do { \
+ int dev = autocvar_developer; \
+ bool war = autocvar_prvm_backtraceforwarnings; \
+ cvar_set("developer", "1"); \
+ cvar_set("prvm_backtraceforwarnings", "1"); \
+ print("\n--- CUT HERE ---\n", msg, "\n"); \
+ _backtrace(); \
+ print("\n--- CUT UNTIL HERE ---\n"); \
+ cvar_set("developer", ftos(dev)); \
+ cvar_set("prvm_backtraceforwarnings", ftos(war)); \
+} while (0)
+
+#endif