aboutsummaryrefslogtreecommitdiff
path: root/include/armnn/Logging.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/armnn/Logging.hpp')
-rw-r--r--include/armnn/Logging.hpp147
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
{