Copy of https://github.com/zimbatm/lograge as I need this commit: 569a49885bf7e61943fd5c31a10cc6f3b7d0eda1