Just moves code. I will think about appling this.
Change-Id: I6e6e21a9144f548697acc0f959e7aa2338831121
XMLSEC1_DEPS
Boost
)
+# Target in-package deps
+TARGET_LINK_LIBRARIES(${TARGET_LIBNAME_SIGNATURE} PUBLIC ${TARGET_LIBNAME_UTILS})
# Extra
SET_TARGET_PROPERTIES(${TARGET_LIBNAME_SIGNATURE} PROPERTIES VERSION ${VERSION})
+++ /dev/null
-// Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
-// Use of this source code is governed by a apache 2.0 license that can be
-// found in the LICENSE file.
-
-#ifndef SIGNATURE_LOGGING_H_
-#define SIGNATURE_LOGGING_H_
-
-#include <iostream>
-#include <sstream>
-
-// TODO(tiwanek): Logging...
-
-namespace detail {
-
-class LogCatcher {
- public:
- LogCatcher() { }
- void operator&(const std::ostream& str) const {
- // TODO(tiwanek): this cast is error-prone - fix it
- std::cerr << static_cast<const std::ostringstream*>(&str)->str()
- << std::endl;
- }
-};
-
-} // namespace detail
-
-#define LOG(LEVEL) \
- ::detail::LogCatcher() & std::ostringstream() << "[" << #LEVEL << "] " \
-
-#endif // SIGNATURE_LOGGING_H_
#include <set>
#include <string>
-#include "signature/marcos.h"
+#include "utils/macros.h"
namespace common_installer {
namespace signature {
#include <utility>
#include <vector>
-#include "signature/logging.h"
-#include "signature/marcos.h"
+#include "utils/logging.h"
+#include "utils/macros.h"
namespace {
const char kExpectedXmlns[] = "http://www.w3.org/2000/09/xmldsig#";
#include <memory>
-#include "signature/marcos.h"
+#include "utils/macros.h"
#include "signature/signature_data.h"
namespace common_installer {
#include <set>
#include <string>
-#include "signature/logging.h"
+#include "utils/logging.h"
#include "signature/signature_data.h"
#include "signature/signature_parser.h"
#include "signature/signature_xmlsec_adaptor.h"
#include <string>
-#include "signature/marcos.h"
+#include "utils/macros.h"
namespace common_installer {
namespace signature {
#include <string>
#include <utility>
-#include "signature/logging.h"
+#include "utils/logging.h"
namespace bai = boost::archive::iterators;
namespace bf = boost::filesystem;
--- /dev/null
+// Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef UTILS_LOGGING_H_
+#define UTILS_LOGGING_H_
+
+#include <cassert>
+#include <iostream>
+#include <sstream>
+
+namespace utils {
+
+enum class LogLevel {
+ LOG_ERROR,
+ LOG_WARNING,
+ LOG_INFO,
+ LOG_DEBUG,
+};
+
+template<LogLevel> struct LogTag;
+template<> struct LogTag<LogLevel::LOG_ERROR> {
+ static constexpr const char* value = "\033[0;31m[ERROR] \033[0m";
+};
+template<> struct LogTag<LogLevel::LOG_WARNING> {
+ static constexpr const char* value = "\033[0;33m[WARNING]\033[0m";
+};
+template<> struct LogTag<LogLevel::LOG_INFO> {
+ static constexpr const char* value = "\033[0;32m[INFO] \033[0m";
+};
+template<> struct LogTag<LogLevel::LOG_DEBUG> {
+ static constexpr const char* value = "\033[0m[DEBUG] \033[0m";
+};
+
+class LogCatcher {
+ public:
+ LogCatcher() { }
+ void operator&(const std::ostream& str) const {
+ // TODO(tiwanek): this cast is error-prone - fix it
+ std::cerr << static_cast<const std::ostringstream*>(&str)->str()
+ << std::endl;
+ }
+};
+
+} // namespace utils
+
+// Simple logging macro of following usage:
+// LOG(LEVEL) << object_1 << object_2 << object_n;
+// where:
+// LEVEL = ERROR | WARNING | INFO | DEBUG
+#define LOG(LEVEL) \
+ ::utils::LogCatcher() & std::ostringstream() \
+ << ::utils::LogTag<::utils::LogLevel::LOG_##LEVEL>::value \
+
+#endif // UTILS_LOGGING_H_
// Use of this source code is governed by a apache 2.0 license that can be
// found in the LICENSE file.
-#ifndef SIGNATURE_MARCOS_H_
-#define SIGNATURE_MARCOS_H_
+#ifndef UTILS_MACROS_H_
+#define UTILS_MACROS_H_
#define DISALLOW_COPY_AND_ASSIGN(CLASS) \
CLASS(const CLASS&) = delete; \
CLASS& operator=(const CLASS&) = delete \
-#endif // SIGNATURE_MARCOS_H_
+#endif // UTILS_MACROS_H_