diff --git a/libkineto/src/Logger.cpp b/libkineto/src/Logger.cpp index 2a407c5a3..a15e3c6e4 100644 --- a/libkineto/src/Logger.cpp +++ b/libkineto/src/Logger.cpp @@ -16,8 +16,8 @@ #include #include #include -#include #include +#include #include #include @@ -30,8 +30,8 @@ namespace KINETO_NAMESPACE { std::atomic_int Logger::severityLevel_{VERBOSE}; std::atomic_int Logger::verboseLogLevel_{-1}; std::atomic Logger::verboseLogModules_{~0ull}; -static std::list& LoggerObservers() { - static std::list observers; +static std::set& LoggerObservers() { + static std::set observers; return observers; } static std::mutex& mutex() { @@ -85,16 +85,12 @@ void Logger::setVerboseLogModules(const std::vector& modules) { void Logger::addLoggerObserver(ILoggerObserver* observer) { std::lock_guard guard(mutex()); - LoggerObservers().push_back(observer); + LoggerObservers().insert(observer); } void Logger::removeLoggerObserver(ILoggerObserver* observer) { std::lock_guard guard(mutex()); - auto& LoggerObservers_ = LoggerObservers(); - auto it = std::find(LoggerObservers_.begin(), LoggerObservers_.end(), observer); - if (it != LoggerObservers_.end()) { - LoggerObservers_.erase(it); - } + LoggerObservers().erase(observer); } } // namespace KINETO_NAMESPACE