Fixing a deadlock in handlers

format_and_encode was called under a lock,
but it may trigger a deadlock if during the repr() or str()
another call to logging is emitted
to fix this, we had to separate format_and_encode into separate methods,
format, and encode, so the formatting would be done outside the lock
and the encoding (which uses the stream's encoding) would be done inside
the lock.

We added a test that re-creates the deadlock without the fix.

(cherry picked from commit 6c8441f1ab2b3be367ff459888ab57610f7a617b)
Signed-off-by: Guy Rozendorn <guy@rzn.co.il>

Conflicts:
	tests/test_more.py
Removing the deprecated RotatingFileHandlerBase

(cherry picked from commit ae3c7cec8a21858fce9bca7aaf377c41d61d4ffc)
Signed-off-by: Guy Rozendorn <guy@rzn.co.il>
Fixing thread-safety issues in file-based handlers

Not all file-related operations were under a lock, now they are.

(cherry picked from commit d9b443be34c618d07e7eaa4dd85b06ba4d725ecf)
Signed-off-by: Guy Rozendorn <guy@rzn.co.il>
version bump