Abstract code, reducing the amount of code

I found the standard library logging module which parts of the code can be more simplified.