Advanced logging (with tests)

Assist from @erwanjegouzo :thumbsup: