diff --git a/src/pystack/_pystack.pyx b/src/pystack/_pystack.pyx index dadb5b39..a949a1ac 100644 --- a/src/pystack/_pystack.pyx +++ b/src/pystack/_pystack.pyx @@ -87,9 +87,9 @@ class NativeReportingMode(enum.Enum): ALL = 1000 -cdef api void log_with_python(const char* message, int level) noexcept: - with contextlib.suppress(UnicodeDecodeError): - LOGGER.log(level, message) +cdef api void log_with_python(const cppstring *message, int level) noexcept: + pymessage = _try_to_decode_string(message) + LOGGER.log(level, pymessage) T = TypeVar("T", bound=Callable[..., Any]) diff --git a/src/pystack/_pystack/logging.cpp b/src/pystack/_pystack/logging.cpp index 0eef3a17..4ac13a73 100644 --- a/src/pystack/_pystack/logging.cpp +++ b/src/pystack/_pystack/logging.cpp @@ -22,7 +22,7 @@ logWithPython(const std::string& message, int level) throw std::runtime_error("Logger is not initialized"); } if (!PyErr_Occurred()) { - log_with_python(message.c_str(), level); + log_with_python(&message, level); } }