diff --git a/trunk/ConsoleDataMigration/ConsoleBackup/ConsoleBackup.cpp b/trunk/ConsoleDataMigration/ConsoleBackup/ConsoleBackup.cpp index f3ecda7..cdedb43 100644 --- a/trunk/ConsoleDataMigration/ConsoleBackup/ConsoleBackup.cpp +++ b/trunk/ConsoleDataMigration/ConsoleBackup/ConsoleBackup.cpp @@ -231,7 +231,7 @@ extern "C" void nnMain(void) { s_CanReadSerialNumber = true; } - common::Logger::GetLoggerInstance()->PrintResultIfFailed(result, __LINE__); + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); common::HardwareInfo hwInfo; hwInfo.AddCheckDigit(reinterpret_cast(s_SerialNo)); @@ -239,21 +239,21 @@ extern "C" void nnMain(void) // デバイスIDの取得 bit32 deviceId; result = nn::ps::CTR::GetDeviceId(&deviceId); - common::Logger::GetLoggerInstance()->PrintResultIfFailed(result, __LINE__); + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); // MACアドレスの取得 nn::nwm::Mac mac; char8 macAddress[nn::nwm::Mac::MAC_STRING_SIZE]; result = nn::nwm::GetMacAddress(mac); - common::Logger::GetLoggerInstance()->PrintResultIfFailed(result, __LINE__); + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); mac.GetString(macAddress); - common::Logger::GetLoggerInstance()->PrintResultIfFailed(result, __LINE__); + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); // フレンドコードの取得 nn::friends::CTR::FriendKey friendKey; result = nn::friends::CTR::GetMyFriendKey(&friendKey); - common::Logger::GetLoggerInstance()->PrintResultIfFailed(result , __LINE__); + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); u64 friendCode = nn::friends::CTR::FriendKeyToFriendCode(friendKey); // バージョンの取得 diff --git a/trunk/ConsoleDataMigration/ConsoleBackup/Exporter.cpp b/trunk/ConsoleDataMigration/ConsoleBackup/Exporter.cpp index 27e9e3f..940d4f1 100644 --- a/trunk/ConsoleDataMigration/ConsoleBackup/Exporter.cpp +++ b/trunk/ConsoleDataMigration/ConsoleBackup/Exporter.cpp @@ -102,10 +102,7 @@ void DeleteTrash() NN_LOG("Try Delete %ls%ls/\n", currentDirectory.c_str(), entryIndex->entryName); result = nn::fs::TryDeleteDirectoryRecursively((currentDirectory + ::std::wstring( entryIndex->entryName)).c_str()); - if(result.IsFailure()) - { - COMMON_LOGGER_RESULT_WITH_LINE(result , __LINE__); - } + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); } // ファイルならログとAP設定以外は削除する @@ -117,10 +114,7 @@ void DeleteTrash() NN_LOG("Try Delete %ls%ls\n", currentDirectory.c_str(), entryIndex->entryName); result = nn::fs::TryDeleteFile( (currentDirectory + ::std::wstring(entryIndex->entryName)).c_str()); - if(result.IsFailure()) - { - COMMON_LOGGER_RESULT_WITH_LINE(result , __LINE__); - } + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); } } } @@ -146,7 +140,7 @@ void DeleteTrash() else { NN_LOG("failed initialize directory\n"); - COMMON_LOGGER_RESULT_WITH_LINE(result , __LINE__); + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); dir.Finalize(); } @@ -367,10 +361,7 @@ void ExportThreadFunc() nn::Result result; result = nn::fs::MountSpecialArchive(common::NAND_ARCHIVE_NAME, nn::fs::CTR::ARCHIVE_TYPE_CTR_NAND); - if(result.IsFailure()) - { - COMMON_LOGGER_RESULT_WITH_LINE(result , __LINE__); - } + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); result = common::SdMountManager::Mount(); @@ -401,11 +392,7 @@ nn::Result WriteSaveData() nn::Result result; result = nn::fs::MountSpecialArchive(common::NAND_ARCHIVE_NAME, nn::fs::CTR::ARCHIVE_TYPE_CTR_NAND); - if(result.IsFailure()) - { - COMMON_LOGGER_RESULT_WITH_LINE(result , __LINE__); - return result; - } + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); u32 fileNum = 0; u32 fileSize = 0; diff --git a/trunk/ConsoleDataMigration/ConsoleRestore/ConsoleRestore.cpp b/trunk/ConsoleDataMigration/ConsoleRestore/ConsoleRestore.cpp index 079df23..14a2484 100644 --- a/trunk/ConsoleDataMigration/ConsoleRestore/ConsoleRestore.cpp +++ b/trunk/ConsoleDataMigration/ConsoleRestore/ConsoleRestore.cpp @@ -258,26 +258,26 @@ extern "C" void nnMain(void) { s_CanReadSerialNumber = true; } - common::Logger::GetLoggerInstance()->PrintResultIfFailed(result, __LINE__); + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); // デバイスIDの取得 bit32 deviceId; result = nn::ps::CTR::GetDeviceId(&deviceId); - common::Logger::GetLoggerInstance()->PrintResultIfFailed(result, __LINE__); + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); // MACアドレスの取得 nn::nwm::Mac mac; char8 macAddress[nn::nwm::Mac::MAC_STRING_SIZE]; result = nn::nwm::GetMacAddress(mac); - common::Logger::GetLoggerInstance()->PrintResultIfFailed(result, __LINE__); + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); mac.GetString(macAddress); - common::Logger::GetLoggerInstance()->PrintResultIfFailed(result, __LINE__); + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); // フレンドコードの取得 nn::friends::CTR::FriendKey friendKey; result = nn::friends::CTR::GetMyFriendKey(&friendKey); - common::Logger::GetLoggerInstance()->PrintResultIfFailed(result , __LINE__); + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); u64 friendCode = nn::friends::CTR::FriendKeyToFriendCode(friendKey); // バージョンの取得 diff --git a/trunk/ConsoleDataMigration/ConsoleRestore/Controller.cpp b/trunk/ConsoleDataMigration/ConsoleRestore/Controller.cpp index 06c9ddf..ffabb0d 100644 --- a/trunk/ConsoleDataMigration/ConsoleRestore/Controller.cpp +++ b/trunk/ConsoleDataMigration/ConsoleRestore/Controller.cpp @@ -400,7 +400,7 @@ void ControlState(::std::vector& operationMessage, bool& nextStep, if (s_FgNupRetryCount++ < RETRY_MAX) { // エラーのためやり直す - COMMON_LOGGER_RESULT(GetUpdateResult()); + COMMON_LOGGER_RESULT_IF_FAILED(GetUpdateResult()); COMMON_LOGGER("Network Update Failed. Retrying... %d\n", s_FgNupRetryCount); // FGNUP用のスレッドを作るとこからやり直し diff --git a/trunk/ConsoleDataMigration/ConsoleRestore/Importer.cpp b/trunk/ConsoleDataMigration/ConsoleRestore/Importer.cpp index 5a8728a..b56dcbf 100644 --- a/trunk/ConsoleDataMigration/ConsoleRestore/Importer.cpp +++ b/trunk/ConsoleDataMigration/ConsoleRestore/Importer.cpp @@ -267,10 +267,7 @@ bool EqualsIVSFileandIVS() NN_LOG("Failed Allocate Heap!! %s, %d", __FILE__, __LINE__); } } - else - { - COMMON_LOGGER_RESULT_WITH_LINE(result , __LINE__); - } + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); s_CheckedEqualsIVSFileandIVS = true; common::HeapManager::GetHeap()->Free(enc); @@ -396,10 +393,7 @@ void ImportMcuRtc() COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); } - else - { - COMMON_LOGGER_RESULT_WITH_LINE(result , __LINE__); - } + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); common::HeapManager::GetHeap()->Free(buf); } @@ -450,10 +444,7 @@ void InitializeFileSystem() NN_LOG("Try Delete %ls%ls/\n", currentDirectory.c_str(), entryIndex->entryName); result = nn::fs::TryDeleteDirectoryRecursively((currentDirectory + ::std::wstring( entryIndex->entryName)).c_str()); - if (result.IsFailure()) - { - COMMON_LOGGER_RESULT_WITH_LINE(result , __LINE__); - } + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); } // ファイルなら削除する @@ -462,10 +453,7 @@ void InitializeFileSystem() NN_LOG("Try Delete %ls%ls\n", currentDirectory.c_str(), entryIndex->entryName); result = nn::fs::TryDeleteFile( (currentDirectory + ::std::wstring(entryIndex->entryName)).c_str()); - if (result.IsFailure()) - { - COMMON_LOGGER_RESULT_WITH_LINE(result , __LINE__); - } + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); } } @@ -559,16 +547,10 @@ void ImportThreadFunc() nn::Result result; result = nn::fs::MountSpecialArchive(common::NAND_ARCHIVE_NAME, nn::fs::CTR::ARCHIVE_TYPE_CTR_NAND); - if(result.IsFailure()) - { - COMMON_LOGGER_RESULT_WITH_LINE(result , __LINE__); - } + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); result = common::SdMountManager::Mount(); - if(result.IsFailure()) - { - COMMON_LOGGER_RESULT_WITH_LINE(result , __LINE__); - } + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); size_t bufSize = common::HeapManager::GetHeap()->GetAllocatableSize(); NN_LOG("AllocatableSize = %d\n", bufSize); @@ -655,10 +637,7 @@ void ImportNorData() COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); } - else - { - COMMON_LOGGER_RESULT_WITH_LINE(result , __LINE__); - } + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); common::HeapManager::GetHeap()->Free(buf); } @@ -686,10 +665,7 @@ void Cleanup() nn::am::DoCleanup(nn::fs::MEDIA_TYPE_NAND); } } - else - { - COMMON_LOGGER_RESULT_WITH_LINE(result , __LINE__); - } + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); } void DeleteConsoleInitializedFile() @@ -1091,7 +1067,7 @@ bool ReadSetting() else { NN_LOG("configfileLoader Initialize Failed\n"); - COMMON_LOGGER_RESULT_WITH_LINE(result , __LINE__); + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); retval = false; } common::HeapManager::GetHeap()->Free(heapAddr); @@ -1099,7 +1075,7 @@ bool ReadSetting() else { NN_LOG("Can't Allocate Heap\n"); - COMMON_LOGGER_RESULT_WITH_LINE(result , __LINE__); + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); retval = false; } diff --git a/trunk/ConsoleDataMigration/common/CommonLogger.cpp b/trunk/ConsoleDataMigration/common/CommonLogger.cpp index cb31ac5..ffc63b1 100644 --- a/trunk/ConsoleDataMigration/common/CommonLogger.cpp +++ b/trunk/ConsoleDataMigration/common/CommonLogger.cpp @@ -76,21 +76,6 @@ void CommonLogger::PrintResult(const char* fmt, ...) va_end(vlist); } -void CommonLogger::PrintResultIfFailed(nn::Result result, u32 line) -{ - if (result.IsFailure()) - { - if(line != 0) - { - COMMON_LOGGER_RESULT_WITH_LINE(result, line); - } - else - { - COMMON_LOGGER_RESULT(result); - } - } -} - void CommonLogger::ClearLog() { nn::os::CriticalSection::ScopedLock lock(m_CriticalSection); diff --git a/trunk/ConsoleDataMigration/common/CommonLogger.h b/trunk/ConsoleDataMigration/common/CommonLogger.h index b413c17..562ffcd 100644 --- a/trunk/ConsoleDataMigration/common/CommonLogger.h +++ b/trunk/ConsoleDataMigration/common/CommonLogger.h @@ -23,27 +23,29 @@ #include "LogConsole.h" #define COMMON_LOGGER( ... ) (void)common::Logger::GetLoggerInstance()->Print(__VA_ARGS__) -#define COMMON_LOGGER_RESULT(result) \ +#define COMMON_LOGGER_RESULT(result, func) \ (void)nn::dbg::PrintResult(result); \ + (void)common::Logger::GetLoggerInstance()->PrintResult("Func = %s\n", func); \ (void)common::Logger::GetLoggerInstance()->PrintResult("Result = %X\n", result.GetPrintableBits()); \ -#define COMMON_LOGGER_RESULT_WITH_LINE(result, line) \ +#define COMMON_LOGGER_RESULT_WITH_LINE(result, line, func) \ (void)nn::dbg::detail::Printf("%d\n", line); \ (void)nn::dbg::PrintResult(result); \ + (void)common::Logger::GetLoggerInstance()->PrintResult("Func = %s\n", func); \ (void)common::Logger::GetLoggerInstance()->PrintResult("line = %d\n", line); \ (void)common::Logger::GetLoggerInstance()->PrintResult("Result = %X\n", result.GetPrintableBits()); \ #define COMMON_LOGGER_RESULT_IF_FAILED(result) \ if(result.IsFailure()) \ { \ - COMMON_LOGGER_RESULT(result); \ + COMMON_LOGGER_RESULT(result, __func__); \ } \ -#define COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result) \ - if(result.IsFailure()) \ - { \ - COMMON_LOGGER_RESULT_WITH_LINE(result, __LINE__); \ - } \ +#define COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result) \ + if(result.IsFailure()) \ + { \ + COMMON_LOGGER_RESULT_WITH_LINE(result, __LINE__, __func__); \ + } \ namespace common { @@ -62,7 +64,6 @@ public: void Print(const char* fmt, ...); void PrintResult(const char* fmt, ...); - void PrintResultIfFailed(nn::Result result, u32 line = 0); void ClearLog(); void ScrollUp(); void ScrollDown(); diff --git a/trunk/ConsoleDataMigration/common/PlayHistoryManager.cpp b/trunk/ConsoleDataMigration/common/PlayHistoryManager.cpp index 8288ce2..32c8f7e 100644 --- a/trunk/ConsoleDataMigration/common/PlayHistoryManager.cpp +++ b/trunk/ConsoleDataMigration/common/PlayHistoryManager.cpp @@ -153,10 +153,7 @@ void PlayHistoryManager::Import() } } - else - { - COMMON_LOGGER_RESULT_WITH_LINE(result , __LINE__); - } + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); common::HeapManager::GetHeap()->Free(buf); }