I shall describe a canonical bundle formula which is useful to study the failure of generic smoothness, and give an outline of its proof. This is joint work with Zsolt Patakfalvi.