diff --git a/emper/Debug.cpp b/emper/Debug.cpp index 08f13c59a10d272e48c77723054584ef8c4a3d92..b97d82f3b778efa54584e79439e462434e0c13ad 100644 --- a/emper/Debug.cpp +++ b/emper/Debug.cpp @@ -2,6 +2,8 @@ // Copyright © 2020 Florian Schmaus #include "Debug.hpp" +#include <pthread.h> + #include <chrono> #include <ctime> // for localtime #include <iomanip> // for operator<<, setfill, setw @@ -10,9 +12,13 @@ #include "Common.hpp" #include "Emper.hpp" -#include "Worker.hpp" // for Runtime +#include "Runtime.hpp" +#include "Worker.hpp" #include "emper-common.h" // for workerid_t #include "emper-config.h" // for EMPER_LOG_LEVEL +#include "io/GlobalIoContext.hpp" + +using emper::io::GlobalIoContext; static std::mutex emper_log_mutex; @@ -39,7 +45,14 @@ void emper_log(const std::string& prefix, const std::string& message) { std::string workerIdAsString = std::to_string(workerId); logMessage << std::setfill('0') << std::setw(3) << workerIdAsString << " "; } else { - logMessage << " "; + // Are we the global IO completer + Runtime* runtime = Runtime::getRuntime(); + GlobalIoContext* gio = runtime ? runtime->globalIo : nullptr; + if (gio && pthread_self() == gio->globalCompleter) { + logMessage << "IOC "; + } else { + logMessage << " "; + } } if constexpr (emper::LOG_TIMESTAMP) { diff --git a/emper/Runtime.hpp b/emper/Runtime.hpp index 6b39db70c52ccb42bdff0a222cd02a971b12ef31..e433efea9f949ad4f0eec0d405dc67475997ac3e 100644 --- a/emper/Runtime.hpp +++ b/emper/Runtime.hpp @@ -13,6 +13,7 @@ #include <mutex> #include <optional> #include <random> +#include <string> #include <vector> // for vector #include "CallerEnvironment.hpp" @@ -194,4 +195,6 @@ class Runtime : public Logger<LogSubsystem::RUNTI> { friend class MemoryManager; template <typename> friend class WorkerLocalData; + + friend void emper_log(const std::string& prefix, const std::string& message); }; diff --git a/emper/io/GlobalIoContext.cpp b/emper/io/GlobalIoContext.cpp index e7bb9982a6c574a8c14d7b185e53cdf21a524682..161ccd8b5d4fe4f366d705ceb8b2d48641c65e93 100644 --- a/emper/io/GlobalIoContext.cpp +++ b/emper/io/GlobalIoContext.cpp @@ -9,7 +9,6 @@ #include <cassert> #include <cerrno> #include <cstdio> -#include <memory> #include <mutex> #include "CallerEnvironment.hpp" diff --git a/emper/io/GlobalIoContext.hpp b/emper/io/GlobalIoContext.hpp index 78dc214d21492656a27b59530a8a5927eac21673..6a17f4239a718a33ebda1520b95785ec747d792b 100644 --- a/emper/io/GlobalIoContext.hpp +++ b/emper/io/GlobalIoContext.hpp @@ -6,6 +6,7 @@ #include <cstdint> #include <mutex> +#include <string> #include "emper-common.h" #include "io/IoContext.hpp" @@ -14,6 +15,7 @@ class Runtime; namespace emper::io { class GlobalIoContext : public IoContext { friend Runtime; + friend void ::emper_log(const std::string& prefix, const std::string& message); friend class Future; friend class SendFuture; friend class RecvFuture;