diff options
author | Matthew Bentham <Matthew.Bentham@arm.com> | 2020-01-15 17:21:38 +0000 |
---|---|---|
committer | Matthew Bentham <Matthew.Bentham@arm.com> | 2020-01-16 09:19:56 +0000 |
commit | d3a07830771ac6ea0ce3a4d12bfb473cd9a5565d (patch) | |
tree | 03eefc27c29d76293bbf18ace2d1b94da3ec4239 /include/armnn | |
parent | c3da2680f605e705c95811c7ba93770e200e5dc0 (diff) | |
download | armnn-d3a07830771ac6ea0ce3a4d12bfb473cd9a5565d.tar.gz |
Remove use of boost from Logging.hpp
This helps prevent leaking of boost names into Arm NN public headers.
Change-Id: I1605d2ed178965f8e502bc6a4b4ac3e627bbbbed
Signed-off-by: Matthew Bentham <Matthew.Bentham@arm.com>
Diffstat (limited to 'include/armnn')
-rw-r--r-- | include/armnn/Logging.hpp | 147 |
1 files changed, 3 insertions, 144 deletions
diff --git a/include/armnn/Logging.hpp b/include/armnn/Logging.hpp index af6b813c85..45f3f80217 100644 --- a/include/armnn/Logging.hpp +++ b/include/armnn/Logging.hpp @@ -5,26 +5,9 @@ #pragma once +#include <armnn/Utils.hpp> #include <iostream> -#include "Utils.hpp" - - -#if defined(_MSC_VER) -#ifndef NOMINMAX -#define NOMINMAX // Prevent definition of min/max macros that interfere with std::min/max -#endif -#include <Windows.h> -#undef TIME_MS // Windows.h defines this but we don't need it and it interferes with our definition in Instrument.hpp -#endif - -#if defined(__ANDROID__) -#include <android/log.h> -#endif - -#include <boost/assert.hpp> -#include <boost/core/ignore_unused.hpp> - namespace armnn { @@ -59,49 +42,6 @@ private: }; -class StandardOutputColourSink : public LogSink -{ -public: - StandardOutputColourSink(LogSeverity level = LogSeverity::Info) - : m_Level(level) - { - } - - void Consume(const std::string& s) override - { - std::cout << GetColour(m_Level) << s << ResetColour() << std::endl; - } - -private: - std::string ResetColour() - { - return "\033[0m"; - } - - std::string GetColour(LogSeverity level) - { - switch(level) - { - case LogSeverity::Trace: - return "\033[35m"; - case LogSeverity::Debug: - return "\033[32m"; - case LogSeverity::Info: - return "\033[0m"; - case LogSeverity::Warning: - return "\033[33m"; - case LogSeverity::Error: - return "\033[31m"; - case LogSeverity::Fatal: - return "\033[41;30m"; - - default: - return "\033[0m"; - } - } - LogSeverity m_Level; -}; - class StandardOutputSink : public LogSink { public: @@ -111,23 +51,6 @@ public: } }; -class DebugOutputSink : public LogSink -{ -public: - void Consume(const std::string& s) override - { - boost::ignore_unused(s); -#if defined(_MSC_VER) - OutputDebugString(s.c_str()); - OutputDebugString("\n"); -#elif defined(__ANDROID__) - __android_log_write(ANDROID_LOG_DEBUG, "armnn", s.c_str()); -#else - boost::ignore_unused(s); -#endif - } -}; - struct ScopedRecord { ScopedRecord(const std::vector<std::shared_ptr<LogSink>>& sinks, LogSeverity level, bool enabled) @@ -216,73 +139,9 @@ private: bool m_Enable; }; -inline void SetLogFilter(LogSeverity level) -{ - SimpleLogger<LogSeverity::Trace>::Get().Enable(false); - SimpleLogger<LogSeverity::Debug>::Get().Enable(false); - SimpleLogger<LogSeverity::Info>::Get().Enable(false); - SimpleLogger<LogSeverity::Warning>::Get().Enable(false); - SimpleLogger<LogSeverity::Error>::Get().Enable(false); - SimpleLogger<LogSeverity::Fatal>::Get().Enable(false); - switch (level) - { - case LogSeverity::Trace: - SimpleLogger<LogSeverity::Trace>::Get().Enable(true); - ARMNN_FALLTHROUGH; - case LogSeverity::Debug: - SimpleLogger<LogSeverity::Debug>::Get().Enable(true); - ARMNN_FALLTHROUGH; - case LogSeverity::Info: - SimpleLogger<LogSeverity::Info>::Get().Enable(true); - ARMNN_FALLTHROUGH; - case LogSeverity::Warning: - SimpleLogger<LogSeverity::Warning>::Get().Enable(true); - ARMNN_FALLTHROUGH; - case LogSeverity::Error: - SimpleLogger<LogSeverity::Error>::Get().Enable(true); - ARMNN_FALLTHROUGH; - case LogSeverity::Fatal: - SimpleLogger<LogSeverity::Fatal>::Get().Enable(true); - break; - default: - BOOST_ASSERT(false); - } -} +void SetLogFilter(LogSeverity level); -template<LogSeverity Level> -inline void SetLoggingSinks(bool standardOut, bool debugOut, bool coloured) -{ - SimpleLogger<Level>::Get().RemoveAllSinks(); - - if (standardOut) - { - if (coloured) - { - SimpleLogger<Level>::Get().AddSink( - std::make_shared<StandardOutputColourSink>(Level)); - } else - { - SimpleLogger<Level>::Get().AddSink( - std::make_shared<StandardOutputSink>()); - } - } - - if (debugOut) - { - SimpleLogger<Level>::Get().AddSink( - std::make_shared<DebugOutputSink>()); - } -} - -inline void SetAllLoggingSinks(bool standardOut, bool debugOut, bool coloured) -{ - SetLoggingSinks<LogSeverity::Trace>(standardOut, debugOut, coloured); - SetLoggingSinks<LogSeverity::Debug>(standardOut, debugOut, coloured); - SetLoggingSinks<LogSeverity::Info>(standardOut, debugOut, coloured); - SetLoggingSinks<LogSeverity::Warning>(standardOut, debugOut, coloured); - SetLoggingSinks<LogSeverity::Error>(standardOut, debugOut, coloured); - SetLoggingSinks<LogSeverity::Fatal>(standardOut, debugOut, coloured); -} +void SetAllLoggingSinks(bool standardOut, bool debugOut, bool coloured); enum class BoostLogSeverityMapping { |