Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F125819
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
8 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/util/debug.cpp b/util/debug.cpp
index ca3a56cd..2d959481 100644
--- a/util/debug.cpp
+++ b/util/debug.cpp
@@ -1,134 +1,213 @@
#include "debug.h"
#include <iostream>
#include <string>
+#include <stdio.h>
#ifdef ANDROID
#include <android/log.h>
#define ANDROID_LOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, "paintown", __VA_ARGS__)
#endif
using namespace std;
static int global_debug_level = 0;
namespace Global{
#ifdef ANDROID
-
android_ostream::android_ostream(bool enabled):
enabled(enabled){
}
android_ostream & operator<<(android_ostream & stream, const std::string & input){
stream.buffer << input;
return stream;
}
android_ostream & operator<<(android_ostream & stream, const char * input){
stream.buffer << input;
return stream;
}
android_ostream & operator<<(android_ostream & stream, const char input){
stream.buffer << input;
return stream;
}
android_ostream & operator<<(android_ostream & stream, const double input){
stream.buffer << input;
return stream;
}
android_ostream & operator<<(android_ostream & stream, const int input){
stream.buffer << input;
return stream;
}
android_ostream & operator<<(android_ostream & stream, const short int input){
stream.buffer << input;
return stream;
}
android_ostream & operator<<(android_ostream & stream, const short unsigned int input){
stream.buffer << input;
return stream;
}
android_ostream & operator<<(android_ostream & stream, const unsigned int input){
stream.buffer << input;
return stream;
}
android_ostream & operator<<(android_ostream & stream, const bool input){
stream.buffer << input;
return stream;
}
android_ostream & operator<<(android_ostream & stream, const long int input){
stream.buffer << input;
return stream;
}
android_ostream & operator<<(android_ostream & stream, const unsigned long int input){
stream.buffer << input;
return stream;
}
android_ostream & operator<<(android_ostream & stream, const void * input){
stream.buffer << input;
return stream;
}
android_ostream & operator<<(android_ostream & stream, std::ostream & (*f)(std::ostream &)){
if (stream.enabled){
ANDROID_LOGV("%s\n", stream.buffer.str().c_str());
}
stream.buffer.str("");
stream.buffer.rdbuf()->pubseekoff(0, ios_base::end, ios_base::out);
stream.buffer.clear();
return stream;
}
android_ostream android_ostream::stream;
static android_ostream nullcout(false);
+#elif defined(WII) && defined(DEBUG)
+wii_ostream::wii_ostream(bool enabled):
+enabled(enabled){
+}
+
+wii_ostream & operator<<(wii_ostream & stream, const std::string & input){
+ stream.buffer << input;
+ return stream;
+}
+
+wii_ostream & operator<<(wii_ostream & stream, const char * input){
+ stream.buffer << input;
+ return stream;
+}
+
+wii_ostream & operator<<(wii_ostream & stream, const char input){
+ stream.buffer << input;
+ return stream;
+}
+
+wii_ostream & operator<<(wii_ostream & stream, const double input){
+ stream.buffer << input;
+ return stream;
+}
+
+wii_ostream & operator<<(wii_ostream & stream, const int input){
+ stream.buffer << input;
+ return stream;
+}
+
+wii_ostream & operator<<(wii_ostream & stream, const short int input){
+ stream.buffer << input;
+ return stream;
+}
+
+wii_ostream & operator<<(wii_ostream & stream, const short unsigned int input){
+ stream.buffer << input;
+ return stream;
+}
+
+wii_ostream & operator<<(wii_ostream & stream, const unsigned int input){
+ stream.buffer << input;
+ return stream;
+}
+
+wii_ostream & operator<<(wii_ostream & stream, const bool input){
+ stream.buffer << input;
+ return stream;
+}
+
+wii_ostream & operator<<(wii_ostream & stream, const long int input){
+ stream.buffer << input;
+ return stream;
+}
+
+wii_ostream & operator<<(wii_ostream & stream, const unsigned long int input){
+ stream.buffer << input;
+ return stream;
+}
+
+wii_ostream & operator<<(wii_ostream & stream, const void * input){
+ stream.buffer << input;
+ return stream;
+}
+
+wii_ostream & operator<<(wii_ostream & stream, std::ostream & (*f)(std::ostream &)){
+ if (stream.enabled){
+ printf("%s\n", stream.buffer.str().c_str());
+ }
+ stream.buffer.str("");
+ stream.buffer.rdbuf()->pubseekoff(0, ios_base::end, ios_base::out);
+ stream.buffer.clear();
+ return stream;
+}
+
+wii_ostream wii_ostream::stream;
+static wii_ostream nullcout(false);
#else
class nullstreambuf_t: public std::streambuf {
public:
nullstreambuf_t():std::streambuf(){
}
};
static nullstreambuf_t nullstreambuf;
class nullcout_t: public std::ostream {
public:
nullcout_t():std::ostream(&nullstreambuf){
}
};
static nullcout_t nullcout;
#endif
#ifdef ANDROID
stream_type & default_stream = android_ostream::stream;
+#elif defined(WII) && defined(DEBUG)
+stream_type & default_stream = wii_ostream::stream;
#else
stream_type & default_stream = std::cout;
#endif
}
Global::stream_type & Global::debug(int i, const string & context){
if (global_debug_level >= i){
Global::stream_type & out = default_stream;
out << "[" << i << ":" << context << "] ";
return out;
}
return nullcout;
}
void Global::setDebug( int i ){
global_debug_level = i;
}
int Global::getDebug(){
return global_debug_level;
}
diff --git a/util/debug.h b/util/debug.h
index 6634e7b3..6c13c00d 100644
--- a/util/debug.h
+++ b/util/debug.h
@@ -1,44 +1,69 @@
#ifndef _paintown_debug_h
#define _paintown_debug_h
#include <ostream>
#include <sstream>
namespace Global{
#ifdef ANDROID
class android_ostream: public std::ostream {
public:
android_ostream(bool enabled = true);
static android_ostream stream;
/* make these private at some point */
public:
bool enabled;
std::ostringstream buffer;
};
typedef android_ostream stream_type;
android_ostream & operator<<(android_ostream & stream, const std::string & input);
android_ostream & operator<<(android_ostream & stream, const char * input);
android_ostream & operator<<(android_ostream & stream, const char);
android_ostream & operator<<(android_ostream & stream, const double);
android_ostream & operator<<(android_ostream & stream, const int);
android_ostream & operator<<(android_ostream & stream, const short int);
android_ostream & operator<<(android_ostream & stream, const short unsigned int);
android_ostream & operator<<(android_ostream & stream, const unsigned int);
android_ostream & operator<<(android_ostream & stream, const bool);
android_ostream & operator<<(android_ostream & stream, const long int);
android_ostream & operator<<(android_ostream & stream, const unsigned long int);
android_ostream & operator<<(android_ostream & stream, const void *);
android_ostream & operator<<(android_ostream & stream, std::ostream & (*f)(std::ostream &));
+#elif defined(WII) && defined(DEBUG)
+class wii_ostream: public std::ostream {
+public:
+ wii_ostream(bool enabled = true);
+ static wii_ostream stream;
+ /* make these private at some point */
+public:
+ bool enabled;
+ std::ostringstream buffer;
+};
+
+typedef wii_ostream stream_type;
+wii_ostream & operator<<(wii_ostream & stream, const std::string & input);
+wii_ostream & operator<<(wii_ostream & stream, const char * input);
+wii_ostream & operator<<(wii_ostream & stream, const char);
+wii_ostream & operator<<(wii_ostream & stream, const double);
+wii_ostream & operator<<(wii_ostream & stream, const int);
+wii_ostream & operator<<(wii_ostream & stream, const short int);
+wii_ostream & operator<<(wii_ostream & stream, const short unsigned int);
+wii_ostream & operator<<(wii_ostream & stream, const unsigned int);
+wii_ostream & operator<<(wii_ostream & stream, const bool);
+wii_ostream & operator<<(wii_ostream & stream, const long int);
+wii_ostream & operator<<(wii_ostream & stream, const unsigned long int);
+wii_ostream & operator<<(wii_ostream & stream, const void *);
+wii_ostream & operator<<(wii_ostream & stream, std::ostream & (*f)(std::ostream &));
#else
typedef std::ostream stream_type;
#endif
void setDebug( int i );
int getDebug();
stream_type & debug(int i, const std::string & context = "paintown");
}
#endif
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Jun 11, 9:47 AM (3 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
68195
Default Alt Text
(8 KB)
Attached To
Mode
R75 R-Tech1
Attached
Detach File
Event Timeline