Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __SP_INPUTOUTPUT_LOG_H__
00009 #define __SP_INPUTOUTPUT_LOG_H__
00010
00011
00012 #include "Base/spStandard.hpp"
00013 #include "Base/spInputOutputString.hpp"
00014 #include "Base/spDimension.hpp"
00015 #include "Base/spMaterialColor.hpp"
00016
00017 #include <fstream>
00018 #include <string.h>
00019 #include <boost/function.hpp>
00020
00021 #if defined(SP_PLATFORM_WINDOWS)
00022 # include <io.h>
00023 #elif defined(SP_PLATFORM_LINUX)
00024 # include <cstdio>
00025 #elif defined(SP_PLATFORM_ANDROID)
00026 # include <android/log.h>
00027 #endif
00028
00029
00030 namespace sp
00031 {
00032 namespace io
00033 {
00034
00035
00037 enum ELogTimeFormats
00038 {
00039 LOGTIME_DISABLE,
00040 LOGTIME_HHMMSS,
00041 LOGTIME_MILLISECS,
00042 };
00043
00045 enum ELogMessageFlags
00046 {
00047 LOG_MSGBOX = 0x01,
00048 LOG_TIME = 0x02,
00049 LOG_WARNING = 0x04,
00050 LOG_ERROR = 0x08,
00051 LOG_DEBUG = 0x10,
00052 LOG_NONEWLINE = 0x20,
00053 LOG_NOTAB = 0x40,
00054 };
00055
00057 enum ELogOutputContexts
00058 {
00059 LOGCONTEXT_NONE = 0x00,
00060 LOGCONTEXT_CONSOLE = 0x01,
00061 LOGCONTEXT_FILE = 0x02,
00062 };
00063
00064
00065 #if defined(SP_PLATFORM_ANDROID)
00066 static stringc DEF_DEBUGLOG_FILE = "/mnt/sdcard/spDebugLog.txt";
00067 #else
00068 static stringc DEF_DEBUGLOG_FILE = "spDebugLog.txt";
00069 #endif
00070
00071
00073 namespace Log
00074 {
00075
00076 typedef boost::function<void (const io::stringc &Message, s32 Flags)> MessageCallback;
00077
00078 SP_EXPORT void setMessageCallback(const MessageCallback &Proc);
00079
00086 SP_EXPORT void error(const stringc &Message, s32 Flags = LOG_TIME);
00087
00089 SP_EXPORT void warning(const stringc &Message, s32 Flags = LOG_TIME);
00090
00092 SP_EXPORT void debug(const stringc &ProcName, const stringc &Message = "Invalid arguments", s32 Flags = LOG_TIME);
00093
00095 SP_EXPORT void message(const stringc &Message, s32 Flags = LOG_TIME);
00096
00103 SP_EXPORT void setTimeFormat(const ELogTimeFormats Format);
00104 SP_EXPORT ELogTimeFormats getTimeFormat();
00105
00107 SP_EXPORT void setTabString(const stringc &TabStr);
00108 SP_EXPORT stringc getTabString();
00109
00111 SP_EXPORT stringc getCurrentTab();
00112
00114 SP_EXPORT void upperTab();
00116 SP_EXPORT void lowerTab();
00117
00122 SP_EXPORT void setOutputContext(const s32 Context);
00123 SP_EXPORT s32 getOutputContext();
00124
00129 SP_EXPORT bool open(const stringc &Filename = DEF_DEBUGLOG_FILE);
00130 SP_EXPORT void close();
00131
00133 SP_EXPORT void pause(bool isPaused);
00134
00135 SP_EXPORT void openConsole(const stringc &Title = "");
00136 SP_EXPORT void closeConsole();
00137 SP_EXPORT void clearConsole();
00138 SP_EXPORT void pauseConsole();
00139
00140 SP_EXPORT stringc getFormatedTime();
00141
00146 class ScopedTab
00147 {
00148 public:
00149 ScopedTab()
00150 {
00151 upperTab();
00152 }
00153 ~ScopedTab()
00154 {
00155 lowerTab();
00156 }
00157 };
00158
00159 }
00160
00161
00162 }
00163
00164 }
00165
00166
00167 #endif
00168
00169
00170
00171