tracing: Move raw output code from macro to standalone function