Real-time mud gas logging and sampling during drilling