> ## Documentation Index
> Fetch the complete documentation index at: https://developer.synopsys.com/llms.txt
> Use this file to discover all available pages before exploring further.

# File logging.h

![][C++]

**Location**: `core/logging/logging.h`

## Classes

* [simulation\_framework::core::logging::LoggingInstance](https://developer.synopsys.com/docs/avxcelerate/avxcelerate-simulation-framework/reference/classsimulation__framework_1_1core_1_1logging_1_1LoggingInstance.md)

## Namespaces

* [simulation\_framework](https://developer.synopsys.com/docs/avxcelerate/avxcelerate-simulation-framework/reference/namespacesimulation__framework.md)
* [simulation\_framework::core](https://developer.synopsys.com/docs/avxcelerate/avxcelerate-simulation-framework/reference/namespacesimulation__framework_1_1core.md)
* [simulation\_framework::core::logging](https://developer.synopsys.com/docs/avxcelerate/avxcelerate-simulation-framework/reference/namespacesimulation__framework_1_1core_1_1logging.md)

## Includes

* core/export/simfwk\_core\_export.h
* core/logging/console\_logger.h
* core/logging/i\_logger.h
* \<memory>
* \<string\_view>
* \<vector>

## Included by

* [simulation\_instance.h](https://developer.synopsys.com/docs/avxcelerate/avxcelerate-simulation-framework/reference/simulation__instance_8h.md)

## Source

```cpp theme={null}


#ifndef SIMFWK_CORE_LOGGING_LOGGING_H
#define SIMFWK_CORE_LOGGING_LOGGING_H

#include "core/export/simfwk_core_export.h"
#include "core/logging/console_logger.h"
#include "core/logging/i_logger.h"
#include <memory>
#include <string_view>
#include <vector>

namespace simulation_framework
{
namespace core
{
namespace logging
{

class SIMFWK_CORE_API LoggingInstance
{
  public:
    using ILoggerContainer = std::vector<std::unique_ptr<ILogger>>;

    virtual ~LoggingInstance() = default;

    LoggingInstance(const LoggingInstance&) = delete;
    LoggingInstance& operator=(const LoggingInstance&) = delete;

    static LoggingInstance& GetInstance()
    {
        static LoggingInstance log_instance;
        return log_instance;
    }

    void RegisterLogger(std::unique_ptr<ILogger> logger) { loggers_.push_back(std::move(logger)); }

    void ClearLoggers() { loggers_.clear(); }

    const ILoggerContainer& GetLoggers() const { return loggers_; }

    void Log(LogLevel level, std::string_view message)
    {
        for (const auto& logger : loggers_)
        {
            if (logger)
            {
                logger->Log(level, message);
            }
        }
    }

    void SetLogLevel(LogLevel log_level)
    {
        for (const auto& logger : loggers_)
        {
            if (logger)
            {
                logger->SetCurrentLogLevel(log_level);
            }
        }
    }

  private:
    LoggingInstance() { RegisterLogger(std::make_unique<simulation_framework::core::logging::ConsoleLogger>()); };

    ILoggerContainer loggers_;
};

static inline void SetLogLevel(LogLevel log_level) noexcept
{
    LoggingInstance::GetInstance().SetLogLevel(log_level);
}

static inline void Debug(std::string_view message) noexcept
{
    LoggingInstance::GetInstance().Log(LogLevel::kDebug, message);
}

static inline void Info(std::string_view message) noexcept
{
    LoggingInstance::GetInstance().Log(LogLevel::kInfo, message);
}

static inline void Warning(std::string_view message) noexcept
{
    LoggingInstance::GetInstance().Log(LogLevel::kWarning, message);
}

static inline void Error(std::string_view message) noexcept
{
    LoggingInstance::GetInstance().Log(LogLevel::kError, message);
}

}  // namespace logging
}  // namespace core
}  // namespace simulation_framework

#endif  // SIMFWK_CORE_LOGGING_LOGGING_H
```

[private]: https://img.shields.io/badge/-private-red "private"

[public]: https://img.shields.io/badge/-public-brightgreen "public"

[const]: https://img.shields.io/badge/-const-lightblue "const"

[C++]: https://img.shields.io/badge/language-C%2B%2B-blue "C++"

[protected]: https://img.shields.io/badge/-protected-yellow "protected"

[static]: https://img.shields.io/badge/-static-lightgrey "static"
