diff --git a/klippy/chelper/__init__.py b/klippy/chelper/__init__.py index 851fda70..76d5c4b4 100644 --- a/klippy/chelper/__init__.py +++ b/klippy/chelper/__init__.py @@ -218,6 +218,10 @@ FFI_main = None FFI_lib = None pyhelper_logging_callback = None +# Hepler invoked from C errorf() code to log errors +def logging_callback(msg): + logging.error(FFI_main.string(msg)) + # Return the Foreign Function Interface api to the caller def get_ffi(): global FFI_main, FFI_lib, pyhelper_logging_callback @@ -238,10 +242,8 @@ def get_ffi(): FFI_main.cdef(d) FFI_lib = FFI_main.dlopen(destlib) # Setup error logging - def logging_callback(msg): - logging.error(FFI_main.string(msg)) - pyhelper_logging_callback = FFI_main.callback( - "void func(const char *)", logging_callback) + pyhelper_logging_callback = FFI_main.callback("void func(const char *)", + logging_callback) FFI_lib.set_python_logging_callback(pyhelper_logging_callback) return FFI_main, FFI_lib