diff --git a/RingDebug.cpp b/RingDebug.cpp index be2860b8a4a1d23017505324cbafdb8deb5b3f44..c5475b263fd1d4424e05c71ffb883963e23c71f2 100644 --- a/RingDebug.cpp +++ b/RingDebug.cpp @@ -24,6 +24,7 @@ using namespace RingClientUWP; using namespace Platform; using namespace Windows::UI::Core; +using namespace Windows::Storage; void RingDebug::print(const std::string& message, @@ -53,5 +54,21 @@ RingDebug::print(const std::string& message, OutputDebugString((wString + L"\n").c_str()); /* fire the event. */ - messageToScreen(ref new String(wString.c_str(), wString.length())); -} \ No newline at end of file + auto line = ref new String(wString.c_str(), wString.length()); + messageToScreen(line); + FileIO::AppendTextAsync(_logFile, line+"\n"); +} + +RingClientUWP::RingDebug::RingDebug() +{ + StorageFolder^ storageFolder = ApplicationData::Current->LocalFolder; + + StorageFile^ logFile; + + task<StorageFile^>(storageFolder->CreateFileAsync("debug.log", CreationCollisionOption::ReplaceExisting)).then([this](StorageFile^ file) + { + this->_logFile = file; + }); + +} + diff --git a/RingDebug.h b/RingDebug.h index c7cee0a615dc7a8a94e5cc3b8fa46a6531bf0f96..61e0c2d58cd0d76c20c6cb7beda53bb06274629c 100644 --- a/RingDebug.h +++ b/RingDebug.h @@ -17,6 +17,8 @@ **************************************************************************/ #pragma once +using namespace Windows::Storage; + namespace RingClientUWP { @@ -40,6 +42,8 @@ public: } } + property StorageFile^ _logFile; + /* properties */ /* functions */ @@ -51,7 +55,7 @@ internal: event debugMessageToScreen^ messageToScreen; private: - RingDebug() {}; // singleton + RingDebug(); // singleton }; void WriteLine(String^ str)