summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-08-26 04:32:12 +0200
committerSven Gothel <[email protected]>2020-08-26 04:32:12 +0200
commit2c987fa7cc078af1be4389a489bbbe2b164f5200 (patch)
treeae363b86a7ae39262e1a96e47bb65baef566285b /src
parent023bc55ff692871b6e81adc574af9729df06d84f (diff)
dbt_debug.hpp: Move implementation to dbt_debug.cpp, since we moved to proper C++ functions
Dropping inline will also reduce footprint of library.
Diffstat (limited to 'src')
-rw-r--r--src/direct_bt/CMakeLists.txt1
-rw-r--r--src/direct_bt/dbt_debug.cpp96
2 files changed, 97 insertions, 0 deletions
diff --git a/src/direct_bt/CMakeLists.txt b/src/direct_bt/CMakeLists.txt
index be1b6dba..c8b90ebe 100644
--- a/src/direct_bt/CMakeLists.txt
+++ b/src/direct_bt/CMakeLists.txt
@@ -12,6 +12,7 @@ include_directories(
set (direct_bt_LIB_SRCS
${PROJECT_SOURCE_DIR}/src/direct_bt/dfa_utf8_decode.cpp
${PROJECT_SOURCE_DIR}/src/direct_bt/DBTEnv.cpp
+ ${PROJECT_SOURCE_DIR}/src/direct_bt/dbt_debug.cpp
${PROJECT_SOURCE_DIR}/src/direct_bt/BasicTypes.cpp
${PROJECT_SOURCE_DIR}/src/ieee11073/DataTypes.cpp
${PROJECT_SOURCE_DIR}/src/direct_bt/UUID.cpp
diff --git a/src/direct_bt/dbt_debug.cpp b/src/direct_bt/dbt_debug.cpp
new file mode 100644
index 00000000..ec7fa520
--- /dev/null
+++ b/src/direct_bt/dbt_debug.cpp
@@ -0,0 +1,96 @@
+/*
+ * Author: Sven Gothel <[email protected]>
+ * Copyright (c) 2020 Gothel Software e.K.
+ * Copyright (c) 2020 ZAFENA AB
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "direct_bt/dbt_debug.hpp"
+
+#include <cstdarg>
+
+using namespace direct_bt;
+
+void direct_bt::DBG_PRINT(const char * format, ...) {
+ if(direct_bt::DBTEnv::get().DEBUG) {
+ fprintf(stderr, "[%'9" PRIu64 "] Debug: ", direct_bt::DBTEnv::getElapsedMillisecond());
+ va_list args;
+ va_start (args, format);
+ vfprintf(stderr, format, args);
+ va_end (args);
+ fprintf(stderr, "\n");
+ fflush(stderr);
+ }
+}
+
+void direct_bt::INFO_PRINT(const char * format, ...) {
+ if(direct_bt::DBTEnv::get().VERBOSE) {
+ fprintf(stderr, "[%'9" PRIu64 "] Info: ", direct_bt::DBTEnv::getElapsedMillisecond());
+ va_list args;
+ va_start (args, format);
+ vfprintf(stderr, format, args);
+ va_end (args);
+ fprintf(stderr, "\n");
+ fflush(stderr);
+ }
+}
+
+void direct_bt::ERR_PRINT(const char * format, ...) {
+ fprintf(stderr, "[%'9" PRIu64 "] Error @ %s:%d: ", direct_bt::DBTEnv::getElapsedMillisecond(), __FILE__, __LINE__);
+ va_list args;
+ va_start (args, format);
+ vfprintf(stderr, format, args);
+ va_end (args);
+ fprintf(stderr, "; last errno %d %s\n", errno, strerror(errno));
+ fflush(stderr);
+}
+
+void direct_bt::WARN_PRINT(const char * format, ...) {
+ fprintf(stderr, "[%'9" PRIu64 "] Warning @ %s:%d: ", direct_bt::DBTEnv::getElapsedMillisecond(), __FILE__, __LINE__);
+ va_list args;
+ va_start (args, format);
+ vfprintf(stderr, format, args);
+ va_end (args);
+ fprintf(stderr, "\n");
+ fflush(stderr);
+}
+
+void direct_bt::PLAIN_PRINT(const char * format, ...) {
+ fprintf(stderr, "[%'9" PRIu64 "] ", direct_bt::DBTEnv::getElapsedMillisecond());
+ va_list args;
+ va_start (args, format);
+ vfprintf(stderr, format, args);
+ va_end (args);
+ fprintf(stderr, "\n");
+ fflush(stderr);
+}
+
+void direct_bt::COND_PRINT(const bool condition, const char * format, ...) {
+ if( condition ) {
+ fprintf(stderr, "[%'9" PRIu64 "] ", direct_bt::DBTEnv::getElapsedMillisecond());
+ va_list args;
+ va_start (args, format);
+ vfprintf(stderr, format, args);
+ va_end (args);
+ fprintf(stderr, "\n");
+ fflush(stderr);
+ }
+}