aboutsummaryrefslogtreecommitdiff
path: root/arm_compute/core/utils/logging
diff options
context:
space:
mode:
Diffstat (limited to 'arm_compute/core/utils/logging')
-rw-r--r--arm_compute/core/utils/logging/FilePrinter.h54
-rw-r--r--arm_compute/core/utils/logging/Helpers.h77
-rw-r--r--arm_compute/core/utils/logging/IPrinter.h74
-rw-r--r--arm_compute/core/utils/logging/LogMsgDecorators.h140
-rw-r--r--arm_compute/core/utils/logging/Logger.h176
-rw-r--r--arm_compute/core/utils/logging/LoggerRegistry.h88
-rw-r--r--arm_compute/core/utils/logging/Macros.h68
-rw-r--r--arm_compute/core/utils/logging/Printers.h31
-rw-r--r--arm_compute/core/utils/logging/StdPrinter.h47
-rw-r--r--arm_compute/core/utils/logging/Types.h58
10 files changed, 813 insertions, 0 deletions
diff --git a/arm_compute/core/utils/logging/FilePrinter.h b/arm_compute/core/utils/logging/FilePrinter.h
new file mode 100644
index 0000000000..e2ae95208a
--- /dev/null
+++ b/arm_compute/core/utils/logging/FilePrinter.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2017 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_LOGGING_FILE_PRINTER_H__
+#define __ARM_COMPUTE_LOGGING_FILE_PRINTER_H__
+
+#include "arm_compute/core/utils/logging/IPrinter.h"
+
+#include "arm_compute/core/utils/io/FileHandler.h"
+
+namespace arm_compute
+{
+namespace logging
+{
+/** File Printer */
+class FilePrinter final : public Printer
+{
+public:
+ /** Default Constructor
+ *
+ * @param[in] filename File name
+ */
+ FilePrinter(const std::string &filename);
+
+private:
+ // Inherited methods overridden:
+ void print_internal(const std::string &msg) override;
+
+private:
+ io::FileHandler _handler;
+};
+} // namespace logging
+} // namespace arm_compute
+#endif /* __ARM_COMPUTE_LOGGING_FILE_PRINTER_H__ */
diff --git a/arm_compute/core/utils/logging/Helpers.h b/arm_compute/core/utils/logging/Helpers.h
new file mode 100644
index 0000000000..4bc54e80db
--- /dev/null
+++ b/arm_compute/core/utils/logging/Helpers.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2017 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_LOGGING_HELPERS_H__
+#define __ARM_COMPUTE_LOGGING_HELPERS_H__
+
+#include "arm_compute/core/utils/logging/Types.h"
+#include "support/ToolchainSupport.h"
+
+#include <cstddef>
+#include <cstdio>
+#include <memory>
+#include <sstream>
+#include <string>
+
+namespace arm_compute
+{
+namespace logging
+{
+/** Create a string given a format
+ *
+ * @param[in] fmt String format
+ * @param[in] args Arguments
+ *
+ * @return The formatted string
+ */
+template <typename... Ts>
+inline std::string string_with_format(const std::string &fmt, Ts &&... args)
+{
+ size_t size = support::cpp11::snprintf(nullptr, 0, fmt.c_str(), args...) + 1;
+ auto char_str = support::cpp14::make_unique<char[]>(size);
+ support::cpp11::snprintf(char_str.get(), size, fmt.c_str(), args...);
+ return std::string(char_str.get(), char_str.get() + size - 1);
+}
+/** Wraps a value with angles and returns the string
+ *
+ * @param[in] val Value to wrap
+ *
+ * @return Wrapped string
+ */
+template <typename T>
+inline std::string angle_wrap_value(const T &val)
+{
+ std::ostringstream ss;
+ ss << "[" << val << "]";
+ return ss.str();
+}
+/** Translates a given log level to a string.
+ *
+ * @param[in] log_level @ref LogLevel to be translated to string.
+ *
+ * @return The string describing the logging level.
+ */
+const std::string &string_from_log_level(LogLevel log_level);
+} // namespace logging
+} // namespace arm_compute
+#endif /* __ARM_COMPUTE_LOGGING_HELPERS_H__ */
diff --git a/arm_compute/core/utils/logging/IPrinter.h b/arm_compute/core/utils/logging/IPrinter.h
new file mode 100644
index 0000000000..6b410d4d12
--- /dev/null
+++ b/arm_compute/core/utils/logging/IPrinter.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2017 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_LOGGING_PRINTER_H__
+#define __ARM_COMPUTE_LOGGING_PRINTER_H__
+
+#include "support/Mutex.h"
+
+namespace arm_compute
+{
+namespace logging
+{
+/** Base printer class to be inherited by other printer classes */
+class Printer
+{
+public:
+ /** Default Constructor */
+ Printer()
+ : _mtx()
+ {
+ }
+ /** Prevent instances of this class from being copied */
+ Printer(const Printer &) = delete;
+ /** Prevent instances of this class from being copied */
+ Printer &operator=(const Printer &) = delete;
+ /** Prevent instances of this class from being moved */
+ Printer(Printer &&) = delete;
+ /** Prevent instances of this class from being moved */
+ Printer &operator=(Printer &&) = delete;
+ /** Defaults Destructor */
+ virtual ~Printer() = default;
+ /** Print message
+ *
+ * @param[in] msg Message to print
+ */
+ inline void print(const std::string &msg)
+ {
+ std::lock_guard<arm_compute::Mutex> lock(_mtx);
+ print_internal(msg);
+ }
+
+private:
+ /** Interface to be implemented by the child to print a message
+ *
+ * @param[in] msg Message to print
+ */
+ virtual void print_internal(const std::string &msg) = 0;
+
+private:
+ arm_compute::Mutex _mtx;
+};
+} // namespace logging
+} // namespace arm_compute
+#endif /* __ARM_COMPUTE_LOGGING_PRINTER_H__ */
diff --git a/arm_compute/core/utils/logging/LogMsgDecorators.h b/arm_compute/core/utils/logging/LogMsgDecorators.h
new file mode 100644
index 0000000000..32cb977bf2
--- /dev/null
+++ b/arm_compute/core/utils/logging/LogMsgDecorators.h
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2016, 2017 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_LOGGING_LOG_MSG_DECORATORS_H__
+#define __ARM_COMPUTE_LOGGING_LOG_MSG_DECORATORS_H__
+
+#include "arm_compute/core/utils/logging/Helpers.h"
+#include "arm_compute/core/utils/logging/Types.h"
+
+#include <chrono>
+#include <ctime>
+#include <string>
+#include <thread>
+
+namespace arm_compute
+{
+namespace logging
+{
+/** Log message decorator interface */
+class IDecorator
+{
+public:
+ /** Default Destructor */
+ virtual ~IDecorator() = default;
+ /** Decorates log message
+ *
+ * @param[in] log_msg Log message to decorate
+ */
+ virtual void decorate(LogMsg &log_msg) = 0;
+};
+
+/** String Decorator
+ *
+ * Appends a user defined string in the log message
+ */
+class StringDecorator : public IDecorator
+{
+public:
+ /** Defaults constructor
+ *
+ * @param str Sting to append
+ */
+ StringDecorator(const std::string &str)
+ : _str(str)
+ {
+ _str = angle_wrap_value(str);
+ }
+
+ // Inherited methods overridden:
+ void decorate(LogMsg &log_msg) override
+ {
+ log_msg.raw_ += _str;
+ }
+
+private:
+ std::string _str;
+};
+
+/** Date Decorator
+ *
+ * Appends the date and time in the log message
+ */
+class DateDecorator : public IDecorator
+{
+public:
+ // Inherited methods overridden:
+ void decorate(LogMsg &log_msg) override
+ {
+ log_msg.raw_ += angle_wrap_value(get_time());
+ }
+
+private:
+ /** Gets current system local time
+ *
+ * @return Local time
+ */
+ std::string get_time()
+ {
+ auto now = std::chrono::system_clock::now();
+ auto time = std::chrono::system_clock::to_time_t(now);
+
+ // TODO: use put_time for gcc > 4.9
+ char buf[100] = { 0 };
+ std::strftime(buf, sizeof(buf), "%d-%m-%Y %I:%M:%S", std::localtime(&time));
+ return buf;
+ }
+};
+
+/** Thread ID Decorator
+ *
+ * Appends the thread ID in the log message
+ */
+class ThreadIdDecorator : public IDecorator
+{
+public:
+ // Inherited methods overridden:
+ void decorate(LogMsg &log_msg) override
+ {
+#ifndef NO_MULTI_THREADING
+ log_msg.raw_ += angle_wrap_value(std::this_thread::get_id());
+#endif /* NO_MULTI_THREADING */
+ }
+};
+
+/** Log Level Decorator
+ *
+ * Appends the logging level in the log message
+ */
+class LogLevelDecorator : public IDecorator
+{
+public:
+ // Inherited methods overridden:
+ void decorate(LogMsg &log_msg) override
+ {
+ log_msg.raw_ += angle_wrap_value(string_from_log_level(log_msg.log_level_));
+ }
+};
+} // namespace logging
+} // namespace arm_compute
+#endif /* __ARM_COMPUTE_LOGGING_LOG_MSG_DECORATORS_H__ */
diff --git a/arm_compute/core/utils/logging/Logger.h b/arm_compute/core/utils/logging/Logger.h
new file mode 100644
index 0000000000..eb9bdd2e36
--- /dev/null
+++ b/arm_compute/core/utils/logging/Logger.h
@@ -0,0 +1,176 @@
+/*
+ * Copyright (c) 2017 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_LOGGING_LOGGER_H__
+#define __ARM_COMPUTE_LOGGING_LOGGER_H__
+
+#include "arm_compute/core/utils/logging/Helpers.h"
+#include "arm_compute/core/utils/logging/IPrinter.h"
+#include "arm_compute/core/utils/logging/LogMsgDecorators.h"
+#include "arm_compute/core/utils/logging/Types.h"
+
+#include <memory>
+#include <sstream>
+#include <string>
+#include <vector>
+
+namespace arm_compute
+{
+namespace logging
+{
+/** Logger class */
+class Logger
+{
+public:
+ /** Default Constructor
+ *
+ * @param[in] name Name of the logger
+ * @param[in] log_level Logger log level
+ * @param[in] printer Printer to push the messages
+ */
+ Logger(std::string name, LogLevel log_level, std::shared_ptr<Printer> printer);
+ /** Default Constructor
+ *
+ * @param[in] name Name of the logger
+ * @param[in] log_level Logger log level
+ * @param[in] printers Printers to push the messages
+ */
+ Logger(std::string name, LogLevel log_level, std::vector<std::shared_ptr<Printer>> printers = {});
+ /** Default Constructor
+ *
+ * @param[in] name Name of the logger
+ * @param[in] log_level Logger log level
+ * @param[in] printers Printers to push the messages
+ * @param[in] decorators Message decorators, which append information in the logged message
+ */
+ Logger(std::string name,
+ LogLevel log_level,
+ std::vector<std::shared_ptr<Printer>> printers,
+ std::vector<std::unique_ptr<IDecorator>> decorators);
+ /** Allow instances of this class to be moved */
+ Logger(Logger &&) = default;
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ Logger(const Logger &) = delete;
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ Logger &operator=(const Logger &) = delete;
+ /** Allow instances of this class to be moved */
+ Logger &operator=(Logger &&) = default;
+ /** Logs a message
+ *
+ * @param[in] log_level Log level of the message
+ * @param[in] msg Message to log
+ */
+ void log(LogLevel log_level, const std::string &msg);
+ /** Logs a formatted message
+ *
+ * @param[in] log_level Log level of the message
+ * @param[in] fmt Message format
+ * @param[in] args Message arguments
+ */
+ template <typename... Ts>
+ void log(LogLevel log_level, const std::string &fmt, Ts &&... args);
+ /** Sets log level of the logger
+ *
+ * @warning Not thread-safe
+ *
+ * @param[in] log_level Log level to set
+ */
+ void set_log_level(LogLevel log_level);
+ /** Returns logger's log level
+ *
+ * @return Logger's log level
+ */
+ LogLevel log_level() const;
+ /** Returns logger's name
+ *
+ * @return Logger's name
+ */
+ std::string name() const;
+ /** Adds a printer to the logger
+ *
+ * @warning Not thread-safe
+ *
+ * @param[in] printer
+ */
+ void add_printer(std::shared_ptr<Printer> printer);
+ /** Adds a log message decorator to the logger
+ *
+ * @warning Not thread-safe
+ *
+ * @param[in] decorator
+ */
+ void add_decorator(std::unique_ptr<IDecorator> decorator);
+
+private:
+ /** Set default message decorators */
+ void set_default_decorators();
+ /** Checks if a message should be logged depending
+ * on the message log level and the loggers one
+ *
+ * @param[in] log_level Log level
+ *
+ * @return True if message should be logged else false
+ */
+ bool is_loggable(LogLevel log_level);
+ /** Decorate log message
+ *
+ * @param[in] Log message to decorate
+ */
+ void decorate_log_msg(LogMsg &msg);
+ /** Creates final log message by creating the prefix
+ *
+ * @param[in] str Log message
+ * @param[in] log_level Message's log level
+ *
+ * @return Final log message to print
+ */
+ std::string create_log_msg(const std::string &str, LogLevel log_level);
+ /** Prints the message to all the printers
+ *
+ * @param[in] msg Message to print
+ */
+ void print_all(const std::string &msg);
+
+private:
+ std::string _name;
+ LogLevel _log_level;
+ std::vector<std::shared_ptr<Printer>> _printers;
+ std::vector<std::unique_ptr<IDecorator>> _decorators;
+};
+
+template <typename... Ts>
+inline void Logger::log(LogLevel log_level, const std::string &fmt, Ts &&... args)
+{
+ // Return if message shouldn't be logged
+ // i.e. if log level does not match the logger's
+ if(!is_loggable(log_level))
+ {
+ return;
+ }
+
+ // Print message to all printers
+ print_all(create_log_msg(string_with_format(fmt, args...), log_level));
+}
+} // namespace logging
+} // namespace arm_compute
+#endif /* __ARM_COMPUTE_LOGGING_LOGGER_H__ */
diff --git a/arm_compute/core/utils/logging/LoggerRegistry.h b/arm_compute/core/utils/logging/LoggerRegistry.h
new file mode 100644
index 0000000000..d861476fea
--- /dev/null
+++ b/arm_compute/core/utils/logging/LoggerRegistry.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2017 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_LOGGING_LOGGER_REGISTRY_H__
+#define __ARM_COMPUTE_LOGGING_LOGGER_REGISTRY_H__
+
+#include "arm_compute/core/utils/logging/Logger.h"
+#include "arm_compute/core/utils/logging/Printers.h"
+#include "arm_compute/core/utils/logging/Types.h"
+#include "support/Mutex.h"
+
+#include <memory>
+#include <set>
+#include <unordered_map>
+
+namespace arm_compute
+{
+namespace logging
+{
+/** Registry class holding all the instantiated loggers */
+class LoggerRegistry final
+{
+public:
+ /** Gets registry instance
+ *
+ * @return Logger registry instance
+ */
+ static LoggerRegistry &get();
+ /** Creates a logger
+ *
+ * @note Some names are reserved e.g. [CORE, RUNTIME, GRAPH]
+ *
+ * @param[in] name Logger's name
+ * @param[in] log_level Logger's log level
+ * @param[in] printers Printers to attach to the system loggers
+ */
+ void create_logger(const std::string &name, LogLevel log_level, std::vector<std::shared_ptr<Printer>> printers = {});
+ /** Remove a logger
+ *
+ * @param name Logger's name
+ */
+ void remove_logger(const std::string &name);
+ /** Returns a logger instance
+ *
+ * @param[in] name Logger to return
+ *
+ * @return Logger
+ */
+ std::shared_ptr<Logger> logger(const std::string &name);
+ /** Creates reserved library loggers
+ *
+ * @param[in] log_level Logger's log level
+ * @param[in] printers Printers to attach to the system loggers
+ */
+ void create_reserved_loggers(LogLevel log_level, std::vector<std::shared_ptr<Printer>> printers = {});
+
+private:
+ /** Default constructor */
+ LoggerRegistry();
+
+private:
+ arm_compute::Mutex _mtx;
+ std::unordered_map<std::string, std::shared_ptr<Logger>> _loggers;
+ static std::set<std::string> _reserved_loggers;
+};
+} // namespace logging
+} // namespace arm_compute
+#endif /* __ARM_COMPUTE_LOGGING_LOGGER_REGISTRY_H__ */
diff --git a/arm_compute/core/utils/logging/Macros.h b/arm_compute/core/utils/logging/Macros.h
new file mode 100644
index 0000000000..b17354bed7
--- /dev/null
+++ b/arm_compute/core/utils/logging/Macros.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2017 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_LOGGING_MACROS_H__
+#define __ARM_COMPUTE_LOGGING_MACROS_H__
+
+#include "arm_compute/core/utils/logging/LoggerRegistry.h"
+
+#include <sstream>
+
+#ifdef ARM_COMPUTE_LOGGING_ENABLED
+
+#define ARM_COMPUTE_LOG_MSG(logger_name, log_level, msg) \
+ { \
+ auto logger = arm_compute::logging::LoggerRegistry::get().logger(logger_name); \
+ if(logger != nullptr) \
+ { \
+ logger->log(log_level, msg); \
+ } \
+ }
+
+#define ARM_COMPUTE_LOG_MSG_WITH_FORMAT(logger_name, log_level, fmt, ...) \
+ { \
+ auto logger = arm_compute::logging::LoggerRegistry::get().logger(logger_name); \
+ if(logger != nullptr) \
+ { \
+ logger->log(log_level, fmt, __VA_ARGS__); \
+ } \
+ }
+
+#define ARM_COMPUTE_LOG_STREAM(logger_name, log_level, stream) \
+ { \
+ auto logger = arm_compute::logging::LoggerRegistry::get().logger(logger_name); \
+ if(logger != nullptr) \
+ { \
+ logger->log(log_level, static_cast<std::ostringstream &>(std::ostringstream() << stream).str()); \
+ } \
+ }
+
+#else /* ARM_COMPUTE_LOGGING_ENABLED */
+
+#define ARM_COMPUTE_LOG_MSG(logger_name, log_level, msg)
+#define ARM_COMPUTE_LOG_MSG_WITH_FORMAT(logger_name, log_level, fmt, ...)
+#define ARM_COMPUTE_LOG_STREAM(logger_name, log_level, stream)
+
+#endif /* ARM_COMPUTE_LOGGING_ENABLED */
+
+#endif /* __ARM_COMPUTE_LOGGING_MACROS_H__ */
diff --git a/arm_compute/core/utils/logging/Printers.h b/arm_compute/core/utils/logging/Printers.h
new file mode 100644
index 0000000000..7e5eef6a04
--- /dev/null
+++ b/arm_compute/core/utils/logging/Printers.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2017 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_LOGGING_PRINTERS_H__
+#define __ARM_COMPUTE_LOGGING_PRINTERS_H__
+
+#include "arm_compute/core/utils/logging/FilePrinter.h"
+#include "arm_compute/core/utils/logging/IPrinter.h"
+#include "arm_compute/core/utils/logging/StdPrinter.h"
+
+#endif /* __ARM_COMPUTE_LOGGING_PRINTERS_H__ */
diff --git a/arm_compute/core/utils/logging/StdPrinter.h b/arm_compute/core/utils/logging/StdPrinter.h
new file mode 100644
index 0000000000..0b41b26022
--- /dev/null
+++ b/arm_compute/core/utils/logging/StdPrinter.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2017 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_LOGGING_STD_PRINTER_H__
+#define __ARM_COMPUTE_LOGGING_STD_PRINTER_H__
+
+#include "arm_compute/core/utils/logging/IPrinter.h"
+
+#include <iostream>
+
+namespace arm_compute
+{
+namespace logging
+{
+/** Std Printer */
+class StdPrinter final : public Printer
+{
+private:
+ // Inherited methods overridden:
+ void print_internal(const std::string &msg) override
+ {
+ std::cout << msg << std::endl;
+ }
+};
+} // namespace logging
+} // namespace arm_compute
+#endif /* __ARM_COMPUTE_LOGGING_STD_PRINTER_H__ */
diff --git a/arm_compute/core/utils/logging/Types.h b/arm_compute/core/utils/logging/Types.h
new file mode 100644
index 0000000000..171270d4ef
--- /dev/null
+++ b/arm_compute/core/utils/logging/Types.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2016, 2017 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_LOGGING_TYPES_H__
+#define __ARM_COMPUTE_LOGGING_TYPES_H__
+
+#include <string>
+
+namespace arm_compute
+{
+namespace logging
+{
+/** Logging level enumeration */
+enum class LogLevel : unsigned int
+{
+ VERBOSE, /**< All logging messages */
+ INFO, /**< Information log level */
+ WARN, /**< Warning log level */
+ OFF /**< No logging */
+};
+
+struct LogMsg
+{
+ LogMsg()
+ : raw_(), log_level_(LogLevel::OFF)
+ {
+ }
+ LogMsg(std::string msg, LogLevel log_level = LogLevel::OFF)
+ : raw_(msg), log_level_(log_level)
+ {
+ }
+
+ std::string raw_;
+ LogLevel log_level_;
+};
+} // namespace logging
+} // namespace arm_compute
+#endif /* __ARM_COMPUTE_TYPES_H__ */