Log only when needed