aboutsummaryrefslogtreecommitdiff
path: root/src/server/shared/Debugging
diff options
context:
space:
mode:
authorSpp <spp@jorge.gr>2013-03-25 13:26:48 +0100
committerSpp <spp@jorge.gr>2013-03-25 13:26:48 +0100
commit1a6a23ec96c7646d2753198f93eaba62d2732a83 (patch)
tree2ef7e8ffd5201bd6e7bf0a4ddfd768a24e263e82 /src/server/shared/Debugging
parent7c36e3a298ce243631848b94364c185a863d1526 (diff)
Core/Misc: Minor optimizations (+code changes to reduce differences with 4.3.4 branch)
Core/Logging: Create new logger type "Cheat". Will be used to log all cheat attempts
Diffstat (limited to 'src/server/shared/Debugging')
-rw-r--r--src/server/shared/Debugging/Errors.cpp38
-rw-r--r--src/server/shared/Debugging/Errors.h24
-rw-r--r--src/server/shared/Debugging/WheatyExceptionReport.cpp2
3 files changed, 56 insertions, 8 deletions
diff --git a/src/server/shared/Debugging/Errors.cpp b/src/server/shared/Debugging/Errors.cpp
new file mode 100644
index 00000000000..bd299906de0
--- /dev/null
+++ b/src/server/shared/Debugging/Errors.cpp
@@ -0,0 +1,38 @@
+#include "Errors.h"
+#include "Log.h"
+
+#include <ace/Stack_Trace.h>
+#include <ace/OS_NS_unistd.h>
+
+namespace Trinity {
+
+void Assert(char const *file, int line, char const *function, char const *message)
+{
+ ACE_Stack_Trace st;
+ fprintf(stderr, "\n%s:%i in %s ASSERTION FAILED:\n %s\n%s\n",
+ file, line, function, message, st.c_str());
+ *((volatile int*)NULL) = 0;
+}
+
+void Fatal(char const *file, int line, char const *function, char const *message)
+{
+ sLog->outError(LOG_FILTER_GENERAL, "\n%s:%i in %s FATAL ERROR:\n %s\n",
+ file, line, function, message);
+ ACE_OS::sleep(10);
+ *((volatile int*)NULL) = 0;
+}
+
+void Error(char const *file, int line, char const *function, char const *message)
+{
+ sLog->outError(LOG_FILTER_GENERAL, "\n%s:%i in %s ERROR:\n %s\n",
+ file, line, function, message);
+ *((volatile int*)NULL) = 0;
+}
+
+void Warning(char const *file, int line, char const *function, char const *message)
+{
+ sLog->outError(LOG_FILTER_GENERAL, "\n%s:%i in %s WARNING:\n %s\n",
+ file, line, function, message);
+}
+
+} // namespace Trinity
diff --git a/src/server/shared/Debugging/Errors.h b/src/server/shared/Debugging/Errors.h
index 10e94634e9a..554b20c3648 100644
--- a/src/server/shared/Debugging/Errors.h
+++ b/src/server/shared/Debugging/Errors.h
@@ -19,15 +19,23 @@
#ifndef TRINITYCORE_ERRORS_H
#define TRINITYCORE_ERRORS_H
-#include "Common.h"
-#include "Log.h"
-#include <ace/Stack_Trace.h>
-#include <ace/OS_NS_unistd.h>
+namespace Trinity {
-#define WPAssert(assertion) { if (!(assertion)) { ACE_Stack_Trace st; fprintf(stderr, "\n%s:%i in %s ASSERTION FAILED:\n %s\n%s\n", __FILE__, __LINE__, __FUNCTION__, #assertion, st.c_str()); *((volatile int*)NULL) = 0; } }
-#define WPError(assertion, errmsg) { if (!(assertion)) { sLog->outError(LOG_FILTER_GENERAL, "%\n%s:%i in %s ERROR:\n %s\n", __FILE__, __LINE__, __FUNCTION__, (char *)errmsg); *((volatile int*)NULL) = 0; } }
-#define WPWarning(assertion, errmsg) { if (!(assertion)) { sLog->outError(LOG_FILTER_GENERAL, "\n%s:%i in %s WARNING:\n %s\n", __FILE__, __LINE__, __FUNCTION__, (char *)errmsg); } }
-#define WPFatal(assertion, errmsg) { if (!(assertion)) { sLog->outError(LOG_FILTER_GENERAL, "\n%s:%i in %s FATAL ERROR:\n %s\n", __FILE__, __LINE__, __FUNCTION__, (char *)errmsg); ACE_OS::sleep(10); *((volatile int*)NULL) = 0; } }
+void Assert(char const *file, int line, char const *function, char const *message);
+
+void Fatal(char const *file, int line, char const *function, char const *message);
+
+void Error(char const *file, int line, char const *function, char const *message);
+
+void Warning(char const *file, int line, char const *function, char const *message);
+
+} // namespace Trinity
+
+#define WPAssert(cond) do { if (!(cond)) Trinity::Assert(__FILE__, __LINE__, __FUNCTION__, #cond); } while(0)
+#define WPFatal(cond, msg) do { if (!(cond)) Trinity::Fatal(__FILE__, __LINE__, __FUNCTION__, (msg)); } while(0)
+#define WPError(cond, msg) do { if (!(cond)) Trinity::Error(__FILE__, __LINE__, __FUNCTION__, (msg)); } while(0)
+#define WPWarning(cond, msg) do { if (!(cond)) Trinity::Warning(__FILE__, __LINE__, __FUNCTION__, (msg)); } while(0)
#define ASSERT WPAssert
+
#endif
diff --git a/src/server/shared/Debugging/WheatyExceptionReport.cpp b/src/server/shared/Debugging/WheatyExceptionReport.cpp
index d07e579ab5d..d4bd630ca25 100644
--- a/src/server/shared/Debugging/WheatyExceptionReport.cpp
+++ b/src/server/shared/Debugging/WheatyExceptionReport.cpp
@@ -3,6 +3,8 @@
// MSDN Magazine, 2002
// FILE: WheatyExceptionReport.CPP
//==========================================
+#include "CompilerDefs.h"
+
#if PLATFORM == PLATFORM_WINDOWS && !defined(__MINGW32__)
#define WIN32_LEAN_AND_MEAN
#pragma warning(disable:4996)