Generalize loggin method