diff --git a/iceoryx_platform/win/source/handle_translator.cpp b/iceoryx_platform/win/source/handle_translator.cpp index 1f2c80bd3d..4af0602a74 100644 --- a/iceoryx_platform/win/source/handle_translator.cpp +++ b/iceoryx_platform/win/source/handle_translator.cpp @@ -15,8 +15,10 @@ // SPDX-License-Identifier: Apache-2.0 #include "iceoryx_platform/handle_translator.hpp" +#include "iceoryx_platform/logging.hpp" #include +#include constexpr int HandleTranslator::INVALID_LINUX_FD; @@ -81,8 +83,9 @@ void HandleTranslator::remove(const int linuxFd) noexcept auto iter = m_linuxToWindows.find(linuxFd); if (iter == m_linuxToWindows.end()) { - std::cerr << "Unable to release not registered file handle " << linuxFd << " since it was not acquired" - << std::endl; + std::stringstream stream; + stream << "Unable to release not registered file handle " << linuxFd << " since it was not acquired"; + IOX_PLATFORM_LOG(IOX_PLATFORM_LOG_LEVEL_ERROR, stream.str()); return; } diff --git a/iceoryx_platform/win/source/mman.cpp b/iceoryx_platform/win/source/mman.cpp index 46b70c8aa7..5722858345 100644 --- a/iceoryx_platform/win/source/mman.cpp +++ b/iceoryx_platform/win/source/mman.cpp @@ -16,13 +16,14 @@ #include "iceoryx_platform/mman.hpp" #include "iceoryx_platform/handle_translator.hpp" +#include "iceoryx_platform/logging.hpp" #include "iceoryx_platform/platform_settings.hpp" #include "iceoryx_platform/win32_errorHandling.hpp" -#include #include #include #include +#include #include static std::map handle2segment; @@ -37,10 +38,12 @@ void* mmap(void* addr, size_t length, int prot, int flags, int fd, off_t offset) DWORD numberOfBytesToMap = length; auto printErrorMessage = [&] { - std::cerr << "Failed to map file mapping into process space with mmap( addr = " << std::hex << addr << std::dec - << ", length = " << length << ", [always assume PROT_READ | PROT_WRITE] prot = " << prot - << ", [always assume MAP_SHARED] flags = " << flags << ", fd = " << fd - << ", [always assume 0] offset = " << offset << ")" << std::endl; + std::stringstream stream; + stream << "Failed to map file mapping into process space with mmap( addr = " << std::hex << addr << std::dec + << ", length = " << length << ", [always assume PROT_READ | PROT_WRITE] prot = " << prot + << ", [always assume MAP_SHARED] flags = " << flags << ", fd = " << fd + << ", [always assume 0] offset = " << offset << ")"; + IOX_PLATFORM_LOG(IOX_PLATFORM_LOG_LEVEL_ERROR, stream.str()); }; void* mappedObject = Win32Call(MapViewOfFile, @@ -77,8 +80,10 @@ int munmap(void* addr, size_t length) } else { - std::cerr << "Failed to unmap memory region with munmap( addr = " << std::hex << addr << std::dec - << ", length = " << length << ")" << std::endl; + std::stringstream stream; + stream << "Failed to unmap memory region with munmap( addr = " << std::hex << addr << std::dec + << ", length = " << length << ")"; + IOX_PLATFORM_LOG(IOX_PLATFORM_LOG_LEVEL_ERROR, stream.str()); } return -1; @@ -89,9 +94,11 @@ int iox_shm_open(const char* name, int oflag, mode_t mode) HANDLE sharedMemoryHandle{nullptr}; auto printErrorMessage = [&] { - std::cerr << "Failed to create shared memory with iox_shm_open( name = " << name - << ", [only consider O_CREAT and O_EXCL] oflag = " << oflag - << ", [always assume read, write, execute for everyone] mode = " << mode << ")" << std::endl; + std::stringstream stream; + stream << "Failed to create shared memory with iox_shm_open( name = " << name + << ", [only consider O_CREAT and O_EXCL] oflag = " << oflag + << ", [always assume read, write, execute for everyone] mode = " << mode << ")"; + IOX_PLATFORM_LOG(IOX_PLATFORM_LOG_LEVEL_ERROR, stream.str()); }; bool hasCreatedShm = false; @@ -219,7 +226,9 @@ void internal_iox_shm_set_size(int fd, off_t length) auto iter = handle2segment.find(fd); if (iter == handle2segment.end()) { - std::cerr << "Unable to set shared memory size since the file descriptor is invalid." << std::endl; + std::stringstream stream; + stream << "Unable to set shared memory size since the file descriptor is invalid."; + IOX_PLATFORM_LOG(IOX_PLATFORM_LOG_LEVEL_ERROR, stream.str()); return; } @@ -227,7 +236,9 @@ void internal_iox_shm_set_size(int fd, off_t length) FILE* shm_state = fopen(name.c_str(), "wb"); if (shm_state == NULL) { - std::cerr << "Unable create shared memory state file \"" << name << "\"" << std::endl; + std::stringstream stream; + stream << "Unable create shared memory state file \"" << name << "\""; + IOX_PLATFORM_LOG(IOX_PLATFORM_LOG_LEVEL_ERROR, stream.str()); return; } uint64_t shm_size = length; diff --git a/iceoryx_platform/win/source/win32_errorHandling.cpp b/iceoryx_platform/win/source/win32_errorHandling.cpp index 0ea5ac9340..8409e335f4 100644 --- a/iceoryx_platform/win/source/win32_errorHandling.cpp +++ b/iceoryx_platform/win/source/win32_errorHandling.cpp @@ -19,7 +19,6 @@ #include "iceoryx_platform/logging.hpp" #include -#include #include int __PrintLastErrorToConsole(const char* functionName, const char* file, const int line) noexcept