From 2dc2fffa454daf97f84de53261a7972c50553df0 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Wed, 3 Jul 2019 14:06:44 -0400 Subject: [PATCH] ZmqLogger: default AppendDebugMethod()'s extra params Give the AppendDebugMethod() declaration a set of default values for all parameters after the first. (It uses `""` and `-1.0`, which are what callers were passing in anyway.) This way, callers have the _option_ to eschew this kind of thing: ``` ZmqLogger::Instance()->AppendDebugMethod("Message", "start", start, "length", length, "", -1, "", -1, "", -1, "", -1); ``` instead, they can use the functionally equivalent: ``` ZmqLogger::Instance()->AppendDebugMethod("Message", "start", start, "length", length); ``` Passing meaningless args is the compiler's job, not the programmer's. --- include/ZmqLogger.h | 13 +++++++------ src/ZmqLogger.cpp | 15 ++++++++------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/include/ZmqLogger.h b/include/ZmqLogger.h index 96e16213..84729500 100644 --- a/include/ZmqLogger.h +++ b/include/ZmqLogger.h @@ -96,12 +96,13 @@ namespace openshot { static ZmqLogger * Instance(); /// Append debug information - void AppendDebugMethod(string method_name, string arg1_name, float arg1_value, - string arg2_name, float arg2_value, - string arg3_name, float arg3_value, - string arg4_name, float arg4_value, - string arg5_name, float arg5_value, - string arg6_name, float arg6_value); + void AppendDebugMethod(std::string method_name, + std::string arg1_name="", float arg1_value=-0.0, + std::string arg2_name="", float arg2_value=-0.0, + std::string arg3_name="", float arg3_value=-0.0, + std::string arg4_name="", float arg4_value=-0.0, + std::string arg5_name="", float arg5_value=-0.0, + std::string arg6_name="", float arg6_value=-0.0); /// Close logger (sockets and/or files) void Close(); diff --git a/src/ZmqLogger.cpp b/src/ZmqLogger.cpp index f9ecc875..7cf69228 100644 --- a/src/ZmqLogger.cpp +++ b/src/ZmqLogger.cpp @@ -162,12 +162,13 @@ void ZmqLogger::Close() } // Append debug information -void ZmqLogger::AppendDebugMethod(string method_name, string arg1_name, float arg1_value, - string arg2_name, float arg2_value, - string arg3_name, float arg3_value, - string arg4_name, float arg4_value, - string arg5_name, float arg5_value, - string arg6_name, float arg6_value) +void ZmqLogger::AppendDebugMethod(string method_name, + string arg1_name, float arg1_value, + string arg2_name, float arg2_value, + string arg3_name, float arg3_value, + string arg4_name, float arg4_value, + string arg5_name, float arg5_value, + string arg6_name, float arg6_value) { if (!enabled) // Don't do anything @@ -206,4 +207,4 @@ void ZmqLogger::AppendDebugMethod(string method_name, string arg1_name, float ar // Send message through ZMQ Log(message.str()); } -} \ No newline at end of file +}