--- /dev/null
+/******************************************************************
+ *
+ * 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_ */
+++ /dev/null
-/******************************************************************
- *
- * 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_ */