From 20a33d1ff0fed370652fd775cfc6965e1754f58e Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Tue, 4 Oct 2016 17:39:17 +0100 Subject: [PATCH] Clean up of log handling. --- YSFGateway/YSFGateway.cpp | 2 ++ YSFParrot/YSFParrot.cpp | 12 ++++++++---- YSFReflector/YSFReflector.cpp | 10 +++++----- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index 7f32cfa..d2549fd 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -180,6 +180,7 @@ int CYSFGateway::run() ret = rptNetwork.open(); if (!ret) { ::LogError("Cannot open the repeater network port"); + ::LogFinalise(); return 1; } @@ -189,6 +190,7 @@ int CYSFGateway::run() ret = m_netNetwork->open(); if (!ret) { ::LogError("Cannot open the reflector network port"); + ::LogFinalise(); return 1; } diff --git a/YSFParrot/YSFParrot.cpp b/YSFParrot/YSFParrot.cpp index 198be7f..6927fcb 100644 --- a/YSFParrot/YSFParrot.cpp +++ b/YSFParrot/YSFParrot.cpp @@ -31,14 +31,14 @@ int main(int argc, char** argv) { if (argc == 1) { - ::fprintf(stderr, "Usage: YSFParrot [-d] \n"); + ::fprintf(stderr, "Usage: YSFParrot [-d|--debug] \n"); return 1; } unsigned int n = 1U; bool debug = false; - if (::strcmp(argv[1], "-d") == 0) { + if (::strcmp(argv[1], "-d") == 0 || ::strcmp(argv[1], "--debug") == 0) { debug = true; n = 2U; } @@ -67,12 +67,16 @@ CYSFParrot::~CYSFParrot() void CYSFParrot::run() { - ::LogInitialise(".", "YSFParrot", m_debug ? 1U : 2U, m_debug ? 1U : 2U); + bool ret = ::LogInitialise(".", "YSFParrot", m_debug ? 1U : 2U, m_debug ? 1U : 2U); + if (!ret) { + ::fprintf(stderr, "YSFParrot: unable to open the log file\n"); + return; + } CParrot parrot(180U); CNetwork network(m_port); - bool ret = network.open(); + ret = network.open(); if (!ret) { ::LogFinalise(); return; diff --git a/YSFReflector/YSFReflector.cpp b/YSFReflector/YSFReflector.cpp index 0977edd..cc4417f 100644 --- a/YSFReflector/YSFReflector.cpp +++ b/YSFReflector/YSFReflector.cpp @@ -57,12 +57,10 @@ int main(int argc, char** argv) if ((arg == "-v") || (arg == "--version")) { ::fprintf(stdout, "YSFReflector version %s\n", VERSION); return 0; - } - else if (arg.substr(0, 1) == "-") { + } else if (arg.substr(0, 1) == "-") { ::fprintf(stderr, "Usage: YSFReflector [-v|--version] [filename]\n"); return 1; - } - else { + } else { iniFile = argv[currentArg]; } } @@ -161,8 +159,10 @@ void CYSFReflector::run() CNetwork network(m_conf.getNetworkPort(), m_conf.getName(), m_conf.getDescription(), m_conf.getNetworkDebug()); ret = network.open(); - if (!ret) + if (!ret) { + ::LogFinalise(); return; + } network.setCount(0);