Replace printf with proper tracing