summaryrefslogtreecommitdiffstats
path: root/Tools/MCADefrag/MCADefrag.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2015-09-16 09:12:56 +0200
committerMattes D <github@xoft.cz>2015-09-16 09:12:56 +0200
commitd041057da239d6dca02306849bd62973f3a51c62 (patch)
tree82d3aaa2905d360779ea472bc3baf91f8539758b /Tools/MCADefrag/MCADefrag.cpp
parentMerge pull request #2473 from cuberite/APIDumpRename (diff)
parentIncrease robustness of the logging subsystem (diff)
downloadcuberite-d041057da239d6dca02306849bd62973f3a51c62.tar
cuberite-d041057da239d6dca02306849bd62973f3a51c62.tar.gz
cuberite-d041057da239d6dca02306849bd62973f3a51c62.tar.bz2
cuberite-d041057da239d6dca02306849bd62973f3a51c62.tar.lz
cuberite-d041057da239d6dca02306849bd62973f3a51c62.tar.xz
cuberite-d041057da239d6dca02306849bd62973f3a51c62.tar.zst
cuberite-d041057da239d6dca02306849bd62973f3a51c62.zip
Diffstat (limited to 'Tools/MCADefrag/MCADefrag.cpp')
-rw-r--r--Tools/MCADefrag/MCADefrag.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/Tools/MCADefrag/MCADefrag.cpp b/Tools/MCADefrag/MCADefrag.cpp
index 80c6f5be2..cf1db85d5 100644
--- a/Tools/MCADefrag/MCADefrag.cpp
+++ b/Tools/MCADefrag/MCADefrag.cpp
@@ -22,26 +22,26 @@ static const Byte g_Zeroes[4096] = {0};
int main(int argc, char ** argv)
{
- cLogger::cListener * consoleLogListener = MakeConsoleListener(false);
- cLogger::cListener * fileLogListener = new cFileListener();
- cLogger::GetInstance().AttachListener(consoleLogListener);
- cLogger::GetInstance().AttachListener(fileLogListener);
+ auto consoleLogListener = MakeConsoleListener(false);
+ auto consoleAttachment = cLogger::GetInstance().AttachListener(std::move(consoleLogListener));
+ auto fileLogListenerRet = MakeFileListener();
+ if (!fileLogListenerRet.first)
+ {
+ LOGERROR("Failed to open log file, aborting");
+ return EXIT_FAILURE;
+ }
+ auto fileAttachment = cLogger::GetInstance().AttachListener(std::move(fileLogListenerRet.second));
cLogger::InitiateMultithreading();
cMCADefrag Defrag;
if (!Defrag.Init(argc, argv))
{
- return 1;
+ return EXIT_FAILURE;
}
Defrag.Run();
- cLogger::GetInstance().DetachListener(consoleLogListener);
- delete consoleLogListener;
- cLogger::GetInstance().DetachListener(fileLogListener);
- delete fileLogListener;
-
return 0;
}