Minor point, but maybe limit the version-different stuff to a single line:

```
if sys.version_info[:2] >= (3, 4):
    names = logging._levelNames
else:
    names = logging._nameToLevel
...
```