Moved boost_log_dlog_sink.h to dcm-daemon subdirectory 05/214505/2
authorTomasz Swierczek <t.swierczek@samsung.com>
Mon, 23 Sep 2019 10:26:37 +0000 (12:26 +0200)
committerTomasz Swierczek <t.swierczek@samsung.com>
Mon, 30 Sep 2019 04:15:55 +0000 (04:15 +0000)
This file is not re-used between client & daemon.
This change should improve SAM score.

Change-Id: I6826839da1e37cf9d85813e7de7a13dcc651cf85

dcm-daemon/boost_log_dlog_sink.h [new file with mode: 0644]
shared/boost_log_dlog_sink.h [deleted file]

diff --git a/dcm-daemon/boost_log_dlog_sink.h b/dcm-daemon/boost_log_dlog_sink.h
new file mode 100644 (file)
index 0000000..625c8c0
--- /dev/null
@@ -0,0 +1,108 @@
+/******************************************************************
+ *
+ * Copyright 2017 - 2019 Samsung Electronics All Rights Reserved.
+ *
+ * Author: Jaroslaw Pelczar <j.pelczar@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************/
+
+#ifndef SHARED_BOOST_LOG_DLOG_SINK_H_
+#define SHARED_BOOST_LOG_DLOG_SINK_H_
+
+#include <boost/log/sinks.hpp>
+#include <functional>
+
+#ifdef USE_DLOG_LOGGING
+#include <dlog.h>
+#else
+typedef enum {
+       DLOG_UNKNOWN = 0, /**< Keep this always at the start */
+       DLOG_DEFAULT, /**< Default */
+       DLOG_VERBOSE, /**< Verbose */
+       DLOG_DEBUG, /**< Debug */
+       DLOG_INFO, /**< Info */
+       DLOG_WARN, /**< Warning */
+       DLOG_ERROR, /**< Error */
+       DLOG_FATAL, /**< Fatal */
+       DLOG_SILENT, /**< Silent */
+       DLOG_PRIO_MAX /**< Keep this always at the end. */
+} log_priority;
+#endif
+
+template<typename AttributeValueT = int> class dlog_direct_severity_mapping :
+       public boost::log::sinks::basic_direct_mapping<log_priority, AttributeValueT>
+{
+       typedef  boost::log::sinks::basic_direct_mapping<log_priority, AttributeValueT> base_type;
+public:
+       explicit dlog_direct_severity_mapping(boost::log::attribute_name const& name) :
+               base_type(name)
+       {
+       }
+};
+
+template<typename AttributeValueT = int> class dlog_custom_severity_mapping :
+       public boost::log::sinks::basic_custom_mapping<log_priority, AttributeValueT>
+{
+       typedef  boost::log::sinks::basic_custom_mapping<log_priority, AttributeValueT> base_type;
+public:
+       explicit dlog_custom_severity_mapping(boost::log::attribute_name const& name) :
+               base_type(name, DLOG_DEBUG)
+       {
+       }
+};
+
+class dlog_output_backend :
+       public boost::log::sinks::basic_formatted_sink_backend<char>
+{
+       typedef boost::log::sinks::basic_formatted_sink_backend<char>   base_type;
+       typedef std::function< log_priority (boost::log::record_view const&) > severity_mapper_type;
+
+private:
+       std::string                             log_domain_;
+       severity_mapper_type    level_mapper_;
+
+       inline void send(log_priority level, string_type const& formatted_message) {
+#ifdef USE_DLOG_LOGGING
+               dlog_print(level, log_domain_.c_str(), "%s", formatted_message.c_str());
+#else
+               fprintf(stderr, "%d/(%s): %s\n", level, log_domain_.c_str(), formatted_message.c_str());
+#endif
+       }
+
+public:
+       dlog_output_backend()
+       {
+       }
+
+    void consume(boost::log::record_view const& rec, string_type const& formatted_message) {
+       if(!level_mapper_) {
+               send(DLOG_DEBUG, formatted_message);
+       } else {
+               send(level_mapper_(rec), formatted_message);
+       }
+    }
+
+       void set_log_domain(const std::string& name)
+       {
+               log_domain_ = name;
+       }
+
+    void set_severity_mapper(severity_mapper_type const& mapper)
+    {
+       level_mapper_ = mapper;
+    }
+};
+
+#endif /* SHARED_BOOST_LOG_DLOG_SINK_H_ */
diff --git a/shared/boost_log_dlog_sink.h b/shared/boost_log_dlog_sink.h
deleted file mode 100644 (file)
index 625c8c0..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/******************************************************************
- *
- * Copyright 2017 - 2019 Samsung Electronics All Rights Reserved.
- *
- * Author: Jaroslaw Pelczar <j.pelczar@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
-
-#ifndef SHARED_BOOST_LOG_DLOG_SINK_H_
-#define SHARED_BOOST_LOG_DLOG_SINK_H_
-
-#include <boost/log/sinks.hpp>
-#include <functional>
-
-#ifdef USE_DLOG_LOGGING
-#include <dlog.h>
-#else
-typedef enum {
-       DLOG_UNKNOWN = 0, /**< Keep this always at the start */
-       DLOG_DEFAULT, /**< Default */
-       DLOG_VERBOSE, /**< Verbose */
-       DLOG_DEBUG, /**< Debug */
-       DLOG_INFO, /**< Info */
-       DLOG_WARN, /**< Warning */
-       DLOG_ERROR, /**< Error */
-       DLOG_FATAL, /**< Fatal */
-       DLOG_SILENT, /**< Silent */
-       DLOG_PRIO_MAX /**< Keep this always at the end. */
-} log_priority;
-#endif
-
-template<typename AttributeValueT = int> class dlog_direct_severity_mapping :
-       public boost::log::sinks::basic_direct_mapping<log_priority, AttributeValueT>
-{
-       typedef  boost::log::sinks::basic_direct_mapping<log_priority, AttributeValueT> base_type;
-public:
-       explicit dlog_direct_severity_mapping(boost::log::attribute_name const& name) :
-               base_type(name)
-       {
-       }
-};
-
-template<typename AttributeValueT = int> class dlog_custom_severity_mapping :
-       public boost::log::sinks::basic_custom_mapping<log_priority, AttributeValueT>
-{
-       typedef  boost::log::sinks::basic_custom_mapping<log_priority, AttributeValueT> base_type;
-public:
-       explicit dlog_custom_severity_mapping(boost::log::attribute_name const& name) :
-               base_type(name, DLOG_DEBUG)
-       {
-       }
-};
-
-class dlog_output_backend :
-       public boost::log::sinks::basic_formatted_sink_backend<char>
-{
-       typedef boost::log::sinks::basic_formatted_sink_backend<char>   base_type;
-       typedef std::function< log_priority (boost::log::record_view const&) > severity_mapper_type;
-
-private:
-       std::string                             log_domain_;
-       severity_mapper_type    level_mapper_;
-
-       inline void send(log_priority level, string_type const& formatted_message) {
-#ifdef USE_DLOG_LOGGING
-               dlog_print(level, log_domain_.c_str(), "%s", formatted_message.c_str());
-#else
-               fprintf(stderr, "%d/(%s): %s\n", level, log_domain_.c_str(), formatted_message.c_str());
-#endif
-       }
-
-public:
-       dlog_output_backend()
-       {
-       }
-
-    void consume(boost::log::record_view const& rec, string_type const& formatted_message) {
-       if(!level_mapper_) {
-               send(DLOG_DEBUG, formatted_message);
-       } else {
-               send(level_mapper_(rec), formatted_message);
-       }
-    }
-
-       void set_log_domain(const std::string& name)
-       {
-               log_domain_ = name;
-       }
-
-    void set_severity_mapper(severity_mapper_type const& mapper)
-    {
-       level_mapper_ = mapper;
-    }
-};
-
-#endif /* SHARED_BOOST_LOG_DLOG_SINK_H_ */