diff --git a/Sources/Plasma/NucleusLib/inc/CMakeLists.txt b/Sources/Plasma/NucleusLib/inc/CMakeLists.txt
index 51827345..741a0ac8 100644
--- a/Sources/Plasma/NucleusLib/inc/CMakeLists.txt
+++ b/Sources/Plasma/NucleusLib/inc/CMakeLists.txt
@@ -14,6 +14,7 @@ set(pnNucleusInc_HEADERS
plCreatableStrings.h
plDrawable.h
plgDispatch.h
+ plLoggable.h
plPhysical.h
plPipeline.h
plPipeResReq.h
diff --git a/Sources/Plasma/NucleusLib/inc/plLoggable.h b/Sources/Plasma/NucleusLib/inc/plLoggable.h
new file mode 100644
index 00000000..b64db084
--- /dev/null
+++ b/Sources/Plasma/NucleusLib/inc/plLoggable.h
@@ -0,0 +1,259 @@
+/*==LICENSE==*
+
+CyanWorlds.com Engine - MMOG client, server and tools
+Copyright (C) 2011 Cyan Worlds, Inc.
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see .
+
+Additional permissions under GNU GPL version 3 section 7
+
+If you modify this Program, or any covered work, by linking or
+combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
+NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
+JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
+(or a modified version of those libraries),
+containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
+PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
+JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
+licensors of this Program grant you additional
+permission to convey the resulting work. Corresponding Source for a
+non-source form of such a combination shall include the source code for
+the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
+work.
+
+You can contact Cyan Worlds, Inc. by email legal@cyan.com
+ or by snail mail at:
+ Cyan Worlds, Inc.
+ 14617 N Newport Hwy
+ Mead, WA 99021
+
+*==LICENSE==*/
+#ifndef plLoggable_inc
+#define plLoggable_inc
+
+#include "HeadSpin.h"
+#include "plString.h"
+#include "plFormat.h"
+
+
+// Stub interface implemented by plStatusLog
+class plLog
+{
+public:
+ virtual ~plLog() { }
+
+ virtual bool AddLine(const plString& line) = 0;
+};
+
+
+// An abstract base class which contains a status log and simple functions
+// for writing Debug and Error msgs to the log
+class plLoggable
+{
+protected:
+ mutable plLog* fStatusLog;
+ mutable bool fWeCreatedLog;
+ mutable bool fComplainAboutMissingLog;
+
+
+ // call plStatusLogMgr::CreateStatusLog with the options you want
+ virtual void ICreateStatusLog() const { };
+
+ void IDeleteLog()
+ {
+ if (fWeCreatedLog) {
+ delete fStatusLog;
+ }
+
+ fWeCreatedLog = false;
+ fStatusLog = nullptr;
+ }
+
+public:
+ plLoggable()
+ : fStatusLog(nullptr), fWeCreatedLog(false),
+ fComplainAboutMissingLog(true)
+ { }
+
+ virtual ~plLoggable()
+ {
+ IDeleteLog();
+ }
+
+
+ plLog* GetLog() const
+ {
+ // create status log if necessary
+ if (fStatusLog == nullptr) {
+ ICreateStatusLog(); // Usually overridden by derived class
+
+ if (fStatusLog) {
+ fWeCreatedLog = true;
+ }
+ }
+
+ #ifdef HS_DEBUGGING
+ if (fComplainAboutMissingLog) {
+ hsAssert(fStatusLog, "null log: override ICreateStatusLog()");
+ }
+ #endif
+
+ return fStatusLog;
+ }
+
+
+ void SetLog(plLog* log, bool deleteOnDestruct=false)
+ {
+ IDeleteLog();
+
+ fStatusLog = log;
+ fWeCreatedLog = deleteOnDestruct;
+ }
+
+ // logging
+ virtual bool Log(const plString& str) const
+ {
+ if (str.IsNull() || str.IsEmpty()) {
+ return true;
+ }
+
+ GetLog();
+
+ if (fStatusLog) {
+ return fStatusLog->AddLine(str);
+ }
+
+ return true;
+ }
+
+
+ virtual bool ErrorMsg(const plString& msg) const
+ {
+ return Log(plFormat("ERR: {}", msg));
+ }
+
+ virtual bool WarningMsg(const plString& msg) const
+ {
+ return Log(plFormat("WRN: {}", msg));
+ }
+
+ virtual bool AppMsg(const plString& msg) const
+ {
+ return Log(plFormat("APP: {}", msg));
+ }
+
+ virtual bool DebugMsg(const plString& msg) const
+ {
+ return Log(plFormat("DBG: {}", msg));
+ }
+
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // DEPRECATED Log methods
+ /////////////////////////////////////////////////////////////////////////
+
+ hsDeprecated("plLoggable::Log is deprecated -- use plFormat instead")
+ virtual bool Log( const char * str ) const
+ {
+ return Log(plString::FromUtf8(str));
+ }
+
+ hsDeprecated("plLoggable::LogF is deprecated -- use plFormat instead")
+ virtual bool LogF( const char * fmt, ... ) const
+ {
+ va_list args;
+ va_start(args, fmt);
+ bool ret = Log(plString::IFormat(fmt, args));
+ va_end(args);
+
+ return ret;
+ }
+
+ hsDeprecated("plLoggable::LogV is deprecated -- use plFormat instead")
+ virtual bool LogV( const char * fmt, va_list args ) const
+ {
+ return Log(plString::IFormat(fmt, args));
+ }
+
+ hsDeprecated("plLoggable::ErrorMsgV is deprecated -- use plFormat instead")
+ virtual bool ErrorMsgV(const char* fmt, va_list args) const
+ {
+ return ErrorMsg(plString::IFormat(fmt, args));
+ }
+
+ hsDeprecated("plLoggable::DebugMsgV is deprecated -- use plFormat instead")
+ virtual bool DebugMsgV(const char* fmt, va_list args) const
+ {
+ return DebugMsg(plString::IFormat(fmt, args));
+ }
+
+ hsDeprecated("plLoggable::WarningMsgV is deprecated -- use plFormat instead")
+ virtual bool WarningMsgV(const char* fmt, va_list args) const
+ {
+ return WarningMsg(plString::IFormat(fmt, args));
+ }
+
+ hsDeprecated("plLoggable::AppMsgV is deprecated -- use plFormat instead")
+ virtual bool AppMsgV(const char* fmt, va_list args) const
+ {
+ return AppMsg(plString::IFormat(fmt, args));
+ }
+
+ hsDeprecated("plLoggable::ErrorMsg with format is deprecated -- use plFormat instead")
+ virtual bool ErrorMsg(const char* fmt, ...) const
+ {
+ va_list args;
+ va_start(args, fmt);
+ bool ret = ErrorMsgV(fmt, args);
+ va_end(args);
+
+ return ret;
+ }
+
+ hsDeprecated("plLoggable::DebugMsg with format is deprecated -- use plFormat instead")
+ virtual bool DebugMsg(const char* fmt, ...) const
+ {
+ va_list args;
+ va_start(args, fmt);
+ bool ret = DebugMsgV(fmt, args);
+ va_end(args);
+
+ return ret;
+ }
+
+ hsDeprecated("plLoggable::WarningMsg with format is deprecated -- use plFormat instead")
+ virtual bool WarningMsg(const char* fmt, ...) const
+ {
+ va_list args;
+ va_start(args, fmt);
+ bool ret = WarningMsgV(fmt, args);
+ va_end(args);
+
+ return ret;
+ }
+
+ hsDeprecated("plLoggable::AppMsg with format is deprecated -- use plFormat instead")
+ virtual bool AppMsg(const char* fmt, ...) const
+ {
+ va_list args;
+ va_start(args, fmt);
+ bool ret = AppMsgV(fmt, args);
+ va_end(args);
+
+ return ret;
+ }
+};
+
+#endif // plLoggable_inc
diff --git a/Sources/Plasma/NucleusLib/pnNetCommon/CMakeLists.txt b/Sources/Plasma/NucleusLib/pnNetCommon/CMakeLists.txt
index da5f1101..c8695f43 100644
--- a/Sources/Plasma/NucleusLib/pnNetCommon/CMakeLists.txt
+++ b/Sources/Plasma/NucleusLib/pnNetCommon/CMakeLists.txt
@@ -39,7 +39,6 @@ target_link_libraries(pnNetCommon pnDispatch)
target_link_libraries(pnNetCommon pnFactory)
target_link_libraries(pnNetCommon pnKeyedObject)
target_link_libraries(pnNetCommon pnUUID)
-target_link_libraries(pnNetCommon plStatusLog)
if(WIN32)
target_link_libraries(pnNetCommon ws2_32)
endif(WIN32)
diff --git a/Sources/Plasma/NucleusLib/pnNetCommon/plNetApp.cpp b/Sources/Plasma/NucleusLib/pnNetCommon/plNetApp.cpp
index af69b9e7..b0d2f8ff 100644
--- a/Sources/Plasma/NucleusLib/pnNetCommon/plNetApp.cpp
+++ b/Sources/Plasma/NucleusLib/pnNetCommon/plNetApp.cpp
@@ -58,40 +58,70 @@ void plNetApp::SetInstance(plNetApp* app)
fInstance = app;
}
-bool plNetApp::StaticErrorMsg(const char* fmt, ...)
+
+bool plNetApp::StaticErrorMsg(const plString& msg)
+{
+ if (!GetInstance()) {
+ return true;
+ }
+
+ return GetInstance()->ErrorMsg(msg);
+}
+
+bool plNetApp::StaticWarningMsg(const plString& msg)
{
- if ( !GetInstance() )
+ if (!GetInstance()) {
return true;
+ }
+
+ return GetInstance()->WarningMsg(msg);
+}
+
+bool plNetApp::StaticAppMsg(const plString& msg)
+{
+ if (!GetInstance()) {
+ return true;
+ }
+
+ return GetInstance()->AppMsg(msg);
+}
+
+bool plNetApp::StaticDebugMsg(const plString& msg)
+{
+ if (!GetInstance()) {
+ return true;
+ }
+
+ return GetInstance()->DebugMsg(msg);
+}
+
+
+bool plNetApp::StaticErrorMsg(const char* fmt, ...)
+{
va_list args;
va_start(args, fmt);
- return GetInstance()->ErrorMsgV(fmt, args);
+ return StaticErrorMsg(plString::IFormat(fmt, args));
}
bool plNetApp::StaticDebugMsg(const char* fmt, ...)
{
- if ( !GetInstance() )
- return true;
va_list args;
va_start(args, fmt);
- return GetInstance()->DebugMsgV(fmt, args);
+ return StaticDebugMsg(plString::IFormat(fmt, args));
}
bool plNetApp::StaticWarningMsg(const char* fmt, ...)
{
- if ( !GetInstance() )
- return true;
va_list args;
va_start(args, fmt);
- return GetInstance()->WarningMsgV(fmt, args);
+ return StaticWarningMsg(plString::IFormat(fmt, args));
}
bool plNetApp::StaticAppMsg(const char* fmt, ...)
{
- if ( !GetInstance() )
- return true;
va_list args;
va_start(args, fmt);
- return GetInstance()->AppMsgV(fmt, args);
+ return StaticAppMsg(plString::IFormat(fmt, args));
}
@@ -165,4 +195,4 @@ void plNetClientApp::UnInheritNetMsgFlags(plMessage* msg)
// clear the 'force' option, so it doesn't get sent out again
msg->SetBCastFlag(plMessage::kNetForce | plMessage::kNetNonDeterministic, 0);
}
-}
\ No newline at end of file
+}
diff --git a/Sources/Plasma/NucleusLib/pnNetCommon/plNetApp.h b/Sources/Plasma/NucleusLib/pnNetCommon/plNetApp.h
index f78b2590..13c18b1e 100644
--- a/Sources/Plasma/NucleusLib/pnNetCommon/plNetApp.h
+++ b/Sources/Plasma/NucleusLib/pnNetCommon/plNetApp.h
@@ -46,11 +46,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsBitVector.h"
#include "plNetGroup.h"
+#include "plLoggable.h"
+
#include "pnKeyedObject/hsKeyedObject.h"
#include "pnKeyedObject/plUoid.h"
-#include "plStatusLog/plLoggable.h"
-
#define plVerifyConditionRet(NetApp,cond,ret,str) \
do { \
if (!(cond)) { \
@@ -73,7 +73,7 @@ class plNetMessage;
typedef std::vector plNetMemberList;
typedef std::vector plNetPlayerIDList;
-//
+//
// Common baseclasses for client and server net apps
//
@@ -87,29 +87,43 @@ public:
{
kNullSend=0,
kNetCoreSingleThreaded,
- kScreenMessages, // filter out illegal net game messages, used by gameserver&client
+ kScreenMessages, // filter out illegal net game messages, used by gameserver&client
- FLAG_CEILING = 10 // stay below this or conflict with client/server specific flags
+ FLAG_CEILING = 10 // stay below this or conflict with client/server specific flags
};
static plNetApp* GetInstance();
static void SetInstance(plNetApp* app);
- plNetApp() {}
+ plNetApp() {}
virtual ~plNetApp() {}
- CLASSNAME_REGISTER( plNetApp );
- GETINTERFACE_ANY( plNetApp, hsKeyedObject);
+ CLASSNAME_REGISTER(plNetApp);
+ GETINTERFACE_ANY(plNetApp, hsKeyedObject);
virtual void Shutdown() {}
void SetFlagsBit(int b, bool on=true) { fFlagsVec.SetBit(b, on); }
- bool GetFlagsBit(int b) const { return fFlagsVec.IsBitSet(b) ? true : false; }
+ bool GetFlagsBit(int b) const { return fFlagsVec.IsBitSet(b) ? true : false; }
- static bool StaticWarningMsg(const char* fmt, ...);
+ static bool StaticErrorMsg(const plString& msg);
+ static bool StaticWarningMsg(const plString& msg);
+ static bool StaticAppMsg(const plString& msg);
+ static bool StaticDebugMsg(const plString& msg);
+
+
+ // Deprecated
+ hsDeprecated("StaticErrorMsg with format is deprecated -- use plFormat instead")
static bool StaticErrorMsg(const char* fmt, ...);
- static bool StaticDebugMsg(const char* fmt, ...);
+
+ hsDeprecated("StaticWarningMsg with format is deprecated -- use plFormat instead")
+ static bool StaticWarningMsg(const char* fmt, ...);
+
+ hsDeprecated("StaticAppMsg with format is deprecated -- use plFormat instead")
static bool StaticAppMsg(const char* fmt, ...);
+
+ hsDeprecated("StaticDebugMsg with format is deprecated -- use plFormat instead")
+ static bool StaticDebugMsg(const char* fmt, ...);
};
//
diff --git a/Sources/Plasma/NucleusLib/pnNetCommon/plNetResManager.cpp b/Sources/Plasma/NucleusLib/pnNetCommon/plNetResManager.cpp
index 5b3610d1..8d5030bf 100644
--- a/Sources/Plasma/NucleusLib/pnNetCommon/plNetResManager.cpp
+++ b/Sources/Plasma/NucleusLib/pnNetCommon/plNetResManager.cpp
@@ -66,7 +66,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnKeyedObject/hsKeyedObject.h"
#include "pnFactory/plCreatable.h"
#include "pnNetCommon/plNetApp.h"
-#include "hsStream.h"
+#include "hsStream.h"
plNetResManager::plNetResManager()
{
@@ -83,12 +83,12 @@ plCreatable* plNetResManager::IReadCreatable(hsStream* s) const
{
plCreatable *pCre = plFactory::Create(hClass);
if (!pCre)
- hsAssert( hClass == 0x8000, "Invalid creatable index" );
+ hsAssert(hClass == 0x8000, "Invalid creatable index");
return pCre;
}
- plNetApp::StaticWarningMsg("NetResMgr::Can't create class %s", plFactory::GetNameOfClass(hClass));
+ plNetApp::StaticWarningMsg(plFormat("NetResMgr::Can't create class {}", plFactory::GetNameOfClass(hClass)));
return nil;
}
diff --git a/Sources/Plasma/NucleusLib/pnNetCommon/plSynchedObject.cpp b/Sources/Plasma/NucleusLib/pnNetCommon/plSynchedObject.cpp
index e1483f8c..0ec33105 100644
--- a/Sources/Plasma/NucleusLib/pnNetCommon/plSynchedObject.cpp
+++ b/Sources/Plasma/NucleusLib/pnNetCommon/plSynchedObject.cpp
@@ -209,8 +209,8 @@ bool plSynchedObject::DirtySynchState(const plString& SDLStateName, uint32_t syn
{
#if 0
if (plNetClientApp::GetInstance())
- plNetClientApp::GetInstance()->DebugMsg("NotOKToDirty - Not queueing SDL state, obj %s, sdl %s",
- GetKeyName().c_str(), SDLStateName.c_str());
+ plNetClientApp::GetInstance()->DebugMsg(plFormat("NotOKToDirty - Not queueing SDL state, obj {}, sdl {}",
+ GetKeyName(), SDLStateName));
#endif
return false;
}
@@ -219,8 +219,8 @@ bool plSynchedObject::DirtySynchState(const plString& SDLStateName, uint32_t syn
{
#if 0
if (plNetClientApp::GetInstance())
- plNetClientApp::GetInstance()->DebugMsg("LocalOnly Object - Not queueing SDL msg, obj %s, sdl %s",
- GetKeyName().c_str(), SDLStateName.c_str());
+ plNetClientApp::GetInstance()->DebugMsg(plFormat("LocalOnly Object - Not queueing SDL msg, obj {}, sdl {}",
+ GetKeyName(), SDLStateName));
#endif
return false;
}
@@ -235,8 +235,8 @@ bool plSynchedObject::DirtySynchState(const plString& SDLStateName, uint32_t syn
else
{
if (plNetClientApp::GetInstance())
- plNetClientApp::GetInstance()->DebugMsg("Queueing SDL state with 'maybe' ownership, obj %s, sdl %s",
- GetKeyName().c_str(), SDLStateName.c_str());
+ plNetClientApp::GetInstance()->DebugMsg(plFormat("Queueing SDL state with 'maybe' ownership, obj {}, sdl {}",
+ GetKeyName(), SDLStateName));
}
}
@@ -267,7 +267,7 @@ void plSynchedObject::IAddDirtyState(plKey objKey, const plString& sdlName, uint
if (sendFlags & kForceFullSend)
(*it).fSendFlags |= kForceFullSend;
if (sendFlags & kBCastToClients)
- (*it).fSendFlags |= kBCastToClients;
+ (*it).fSendFlags |= kBCastToClients;
found=true;
break;
}
@@ -281,8 +281,8 @@ void plSynchedObject::IAddDirtyState(plKey objKey, const plString& sdlName, uint
else
{
#if 0
- plNetClientApp::GetInstance()->DebugMsg("Not queueing diplicate request for SDL state, obj %s, sdl %s",
- objKey->GetName().c_str(), sdlName.c_str());
+ plNetClientApp::GetInstance()->DebugMsg(plFormat("Not queueing diplicate request for SDL state, obj {}, sdl {}",
+ objKey->GetName(), sdlName));
#endif
}
}
diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp
index 6fdfa1af..388ceebb 100644
--- a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp
+++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp
@@ -274,31 +274,43 @@ const char* ProcessTab(const char* fmt)
return fmt;
}
+//
+// create StatusLog if necessary
+//
+void plNetClientMgr::ICreateStatusLog() const
+{
+ if (!fStatusLog)
+ {
+ fStatusLog = plStatusLogMgr::GetInstance().CreateStatusLog(40, "network.log",
+ plStatusLog::kTimestamp | plStatusLog::kFilledBackground | plStatusLog::kAlignToTop |
+ plStatusLog::kServerTimestamp);
+ }
+}
+
//
// override for plLoggable
//
-bool plNetClientMgr::Log(const char* str) const
+bool plNetClientMgr::Log(const plString& str) const
{
- if (strlen(str) == 0)
+ if (str.IsNull() || str.IsEmpty()) {
return true;
+ }
// prepend raw time
- plString buf2 = plFormat("{.2f} {}", hsTimer::GetSeconds(), ProcessTab(str));
+ plString buf2 = plFormat("{.2f} {}", hsTimer::GetSeconds(), ProcessTab(str.c_str()));
if ( GetConsoleOutput() )
hsStatusMessage(buf2.c_str());
- // create status log if necessary
- if(fStatusLog==nil)
- {
- fStatusLog = plStatusLogMgr::GetInstance().CreateStatusLog(40, "network.log",
- plStatusLog::kTimestamp | plStatusLog::kFilledBackground | plStatusLog::kAlignToTop |
- plStatusLog::kServerTimestamp);
- fWeCreatedLog = true;
- }
+ GetLog();
plNetObjectDebugger::GetInstance()->LogMsgIfMatch(buf2.c_str());
- return fStatusLog->AddLine(buf2.c_str());
+
+ if (fStatusLog) {
+ return fStatusLog->AddLine(buf2);
+ }
+
+ return true;
}
//
diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.h b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.h
index 196ed715..0e13a7b5 100644
--- a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.h
+++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.h
@@ -237,6 +237,8 @@ private:
int ISendGameMessage(plMessage* msg);
void IDisableNet ();
+ void ICreateStatusLog() const override;
+
public:
plNetClientMgr();
~plNetClientMgr();
@@ -263,7 +265,7 @@ public:
void SendApplyAvatarCustomizationsMsg(const plKey msgReceiver, bool netPropagate=true, bool localPropagate=true);
// plLoggable
- bool Log(const char* str) const;
+ bool Log(const plString& str) const override;
// setters
void SetIniAuthServer(const char * value) { fIniAuthServer=value;}
diff --git a/Sources/Plasma/PubUtilLib/plNetCommon/plNetMsgScreener.h b/Sources/Plasma/PubUtilLib/plNetCommon/plNetMsgScreener.h
index 14ee203c..5425374c 100644
--- a/Sources/Plasma/PubUtilLib/plNetCommon/plNetMsgScreener.h
+++ b/Sources/Plasma/PubUtilLib/plNetCommon/plNetMsgScreener.h
@@ -43,7 +43,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define plNetMsgScreener_h
#include "pnKeyedObject/plKey.h"
-#include "plStatusLog/plLoggable.h"
+#include "plLoggable.h"
//
// Class which decides what game messages are allowed to be sent to the server.
@@ -78,4 +78,4 @@ protected:
virtual bool IAmClient() const = 0;
};
-#endif // plNetMsgScreener_h
\ No newline at end of file
+#endif // plNetMsgScreener_h
diff --git a/Sources/Plasma/PubUtilLib/plStatusLog/CMakeLists.txt b/Sources/Plasma/PubUtilLib/plStatusLog/CMakeLists.txt
index 7ffc5080..4d31c1c3 100644
--- a/Sources/Plasma/PubUtilLib/plStatusLog/CMakeLists.txt
+++ b/Sources/Plasma/PubUtilLib/plStatusLog/CMakeLists.txt
@@ -5,18 +5,19 @@ include_directories("../../PubUtilLib")
set(plStatusLog_SOURCES
plEncryptLogLine.cpp
- plLoggable.cpp
plStatusLog.cpp
)
set(plStatusLog_HEADERS
plEncryptLogLine.h
- plLoggable.h
plStatusLog.h
)
add_library(plStatusLog STATIC ${plStatusLog_SOURCES} ${plStatusLog_HEADERS})
-target_link_libraries(plStatusLog CoreLib plFile plUnifiedTime)
+target_link_libraries(plStatusLog CoreLib)
+target_link_libraries(plStatusLog pnNucleusInc)
+target_link_libraries(plStatusLog plFile)
+target_link_libraries(plStatusLog plUnifiedTime)
source_group("Source Files" FILES ${plStatusLog_SOURCES})
source_group("Header Files" FILES ${plStatusLog_HEADERS})
diff --git a/Sources/Plasma/PubUtilLib/plStatusLog/plLoggable.cpp b/Sources/Plasma/PubUtilLib/plStatusLog/plLoggable.cpp
deleted file mode 100644
index 6ae717d4..00000000
--- a/Sources/Plasma/PubUtilLib/plStatusLog/plLoggable.cpp
+++ /dev/null
@@ -1,181 +0,0 @@
-/*==LICENSE==*
-
-CyanWorlds.com Engine - MMOG client, server and tools
-Copyright (C) 2011 Cyan Worlds, Inc.
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see .
-
-Additional permissions under GNU GPL version 3 section 7
-
-If you modify this Program, or any covered work, by linking or
-combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
-NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
-JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
-(or a modified version of those libraries),
-containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
-PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
-JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
-licensors of this Program grant you additional
-permission to convey the resulting work. Corresponding Source for a
-non-source form of such a combination shall include the source code for
-the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
-work.
-
-You can contact Cyan Worlds, Inc. by email legal@cyan.com
- or by snail mail at:
- Cyan Worlds, Inc.
- 14617 N Newport Hwy
- Mead, WA 99021
-
-*==LICENSE==*/
-#include "plLoggable.h"
-#include "plStatusLog.h"
-#include "hsTemplates.h"
-
-
-plLoggable::~plLoggable()
-{
- IDeleteLog();
-}
-
-void plLoggable::IDeleteLog()
-{
- if ( fWeCreatedLog )
- delete fStatusLog;
- fWeCreatedLog = false;
- fStatusLog = nil;
-}
-
-plStatusLog* plLoggable::GetLog() const
-{
- // create status log if necessary
- if(fStatusLog==nil)
- {
- ICreateStatusLog(); // Usually overridden by derived class
- if ( fStatusLog )
- fWeCreatedLog = true;
- }
-#ifdef HS_DEBUGGING
- if ( fComplainAboutMissingLog )
- {
- hsAssert(fStatusLog, "nil fStatusLog. Should override ICreateStatusLog()");
- }
-#endif
- return fStatusLog;
-}
-
-void plLoggable::SetLog( plStatusLog * log, bool deleteOnDestruct/*=false */)
-{
- IDeleteLog();
- fStatusLog = log;
- fWeCreatedLog = deleteOnDestruct;
-}
-
-
-bool plLoggable::Log( const char * str ) const
-{
- return Log(plString::FromUtf8(str));
-}
-
-bool plLoggable::Log(const plString& str) const
-{
- if (str.IsNull() || str.IsEmpty()) {
- return true;
- }
-
- GetLog();
-
- if (fStatusLog) {
- return fStatusLog->AddLine(str.c_str());
- }
-
- return true;
-}
-
-bool plLoggable::LogF( const char * fmt, ... ) const
-{
- va_list args;
- va_start(args, fmt);
- bool ret = Log(plString::IFormat(fmt, args));
- va_end(args);
-
- return ret;
-}
-
-bool plLoggable::LogV( const char * fmt, va_list args ) const
-{
- return Log(plString::IFormat(fmt, args));
-}
-
-bool plLoggable::DebugMsgV(const char* fmt, va_list args) const
-{
- return Log(plString("DBG: ") + plString::IFormat(fmt, args));
-}
-
-bool plLoggable::ErrorMsgV(const char* fmt, va_list args) const
-{
- return Log(plString("ERR: ") + plString::IFormat(fmt, args));
-}
-
-bool plLoggable::WarningMsgV(const char* fmt, va_list args) const
-{
- return Log(plString("WRN: ") + plString::IFormat(fmt, args));
-}
-
-bool plLoggable::AppMsgV(const char* fmt, va_list args) const
-{
- return Log(plString("APP: ") + plString::IFormat(fmt, args));
-}
-
-///////////////////////////////////////////////////////////////
-
-bool plLoggable::DebugMsg(const char* fmt, ...) const
-{
- va_list args;
- va_start(args, fmt);
- bool ret = DebugMsgV(fmt, args);
- va_end(args);
-
- return ret;
-}
-
-bool plLoggable::ErrorMsg(const char* fmt, ...) const
-{
- va_list args;
- va_start(args, fmt);
- bool ret = ErrorMsgV(fmt, args);
- va_end(args);
-
- return ret;
-}
-
-bool plLoggable::WarningMsg(const char* fmt, ...) const
-{
- va_list args;
- va_start(args, fmt);
- bool ret = WarningMsgV(fmt, args);
- va_end(args);
-
- return ret;
-}
-
-bool plLoggable::AppMsg(const char* fmt, ...) const
-{
- va_list args;
- va_start(args, fmt);
- bool ret = AppMsgV(fmt, args);
- va_end(args);
-
- return ret;
-}
diff --git a/Sources/Plasma/PubUtilLib/plStatusLog/plLoggable.h b/Sources/Plasma/PubUtilLib/plStatusLog/plLoggable.h
deleted file mode 100644
index 091e3dd0..00000000
--- a/Sources/Plasma/PubUtilLib/plStatusLog/plLoggable.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*==LICENSE==*
-
-CyanWorlds.com Engine - MMOG client, server and tools
-Copyright (C) 2011 Cyan Worlds, Inc.
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see .
-
-Additional permissions under GNU GPL version 3 section 7
-
-If you modify this Program, or any covered work, by linking or
-combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
-NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
-JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
-(or a modified version of those libraries),
-containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
-PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
-JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
-licensors of this Program grant you additional
-permission to convey the resulting work. Corresponding Source for a
-non-source form of such a combination shall include the source code for
-the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
-work.
-
-You can contact Cyan Worlds, Inc. by email legal@cyan.com
- or by snail mail at:
- Cyan Worlds, Inc.
- 14617 N Newport Hwy
- Mead, WA 99021
-
-*==LICENSE==*/
-#ifndef plLoggable_inc
-#define plLoggable_inc
-
-#include "HeadSpin.h"
-#include "plString.h"
-
-//
-// An abstract base class which contains a status log and simple functions
-// for writing Debug and Error msgs to the log
-//
-class plStatusLog;
-class plLoggable
-{
-protected:
- mutable plStatusLog* fStatusLog;
- mutable bool fWeCreatedLog;
- mutable bool fComplainAboutMissingLog;
-
- virtual void ICreateStatusLog() const { }; // call plStatusLogMgr::CreateStatusLog with the options you want
- void IDeleteLog();
-
-public:
- plLoggable() : fStatusLog(nil), fWeCreatedLog(false),fComplainAboutMissingLog(true) { }
- virtual ~plLoggable();
-
- plStatusLog* GetLog() const;
- void SetLog( plStatusLog * log, bool deleteOnDestruct=false );
-
- // logging
-
- virtual bool Log( const char * str ) const;
- virtual bool Log(const plString& str) const;
- virtual bool LogF( const char * fmt, ... ) const;
- virtual bool LogV( const char * fmt, va_list args ) const;
- virtual bool ErrorMsgV(const char* fmt, va_list args) const ;
- virtual bool DebugMsgV(const char* fmt, va_list args) const ;
- virtual bool WarningMsgV(const char* fmt, va_list args) const ;
- virtual bool AppMsgV(const char* fmt, va_list args) const ;
- virtual bool ErrorMsg(const char* fmt, ...) const ;
- virtual bool DebugMsg(const char* fmt, ...) const ;
- virtual bool WarningMsg(const char* fmt, ...) const ;
- virtual bool AppMsg(const char* fmt, ...) const ;
-};
-
-#endif // plLoggable_inc
diff --git a/Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp b/Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp
index d9502411..13c1ddbd 100644
--- a/Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp
+++ b/Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp
@@ -495,6 +495,23 @@ bool plStatusLog::IAddLine( const char *line, int32_t count, uint32_t color )
//// AddLine /////////////////////////////////////////////////////////////////
+bool plStatusLog::AddLine(const plString& line)
+{
+ if (fLoggingOff && !fForceLog) {
+ return true;
+ }
+
+ bool ret = true;
+ std::vector lines = line.Split("\n");
+
+ for (plString& str : lines)
+ {
+ ret &= IAddLine(str.c_str(), -1, kWhite);
+ }
+
+ return ret;
+}
+
bool plStatusLog::AddLine( const char *line, uint32_t color )
{
char *c, *str;
diff --git a/Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.h b/Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.h
index 35bd351f..991765ad 100644
--- a/Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.h
+++ b/Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.h
@@ -59,6 +59,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h"
#include "hsThread.h"
#include "plFileSystem.h"
+#include "plLoggable.h"
#include
@@ -70,7 +71,8 @@ class plPipeline;
class plStatusLogMgr;
class plStatusLogDrawerStub;
-class plStatusLog
+
+class plStatusLog : public plLog
{
friend class plStatusLogMgr;
friend class plStatusLogDrawerStub;
@@ -157,6 +159,8 @@ class plStatusLog
~plStatusLog();
+ bool AddLine(const plString& line) override;
+
bool AddLine( const char *line, uint32_t color = kWhite );
/// printf-like functions