Generalize output method and support all message types