feat(examples)(client): updates to work with new logging ownership
This commit is contained in:
parent
b17c160d5c
commit
8489b1e3a2
@ -9,6 +9,7 @@ void ShowLogger();
|
||||
|
||||
int main() {
|
||||
ShowLogger();
|
||||
ICEngine::StartApplication();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -34,11 +35,15 @@ void ShowLogger() {
|
||||
// You can have multiple log streams, ie console + file etc
|
||||
// You do not need to have the same streams for each logger
|
||||
#include <fstream>
|
||||
std::ofstream coreFileStream("core_logs.txt");
|
||||
std::ofstream appFileStream("app_logs.txt");
|
||||
// Create file streams and transfer ownership to the logger
|
||||
// You need to create a unique pointer, because the logger will
|
||||
// take ownership of the streams and clean them up when the app
|
||||
// is complete
|
||||
auto coreFileStream = std::make_unique<std::ofstream>("core_logs.txt");
|
||||
auto appFileStream = std::make_unique<std::ofstream>("app_logs.txt");
|
||||
|
||||
ICEngine::Log::GetCoreLogger()->AddStream(&coreFileStream);
|
||||
ICEngine::Log::GetAppLogger()->AddStream(&appFileStream);
|
||||
ICEngine::Log::GetCoreLogger()->AddStream(std::move(coreFileStream));
|
||||
ICEngine::Log::GetAppLogger()->AddStream(std::move(appFileStream));
|
||||
|
||||
// You can log multiple different types with formatting
|
||||
int age = 30;
|
||||
@ -69,3 +74,14 @@ void ShowLogger() {
|
||||
// The Fatal Handler provides a mechanism for handling unrecoverable errors gracefully, allowing you to define how the application reacts to fatal crashes
|
||||
// LOG_FATAL("This is an example of log fatal crash!");
|
||||
}
|
||||
|
||||
class DemoApp : public ICEngine::ICEApplication {
|
||||
public:
|
||||
void Run() override {
|
||||
LOG_TRACE("Running demo app!");
|
||||
}
|
||||
};
|
||||
|
||||
ICEngine::ICEApplication* ICEngine::CreateICEApplication() {
|
||||
return new DemoApp();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user