logdata function