Move do_log function to chat.h header