Fixed deadlock in loader with multiple threads when there's an error

If there was an error it would deadlock. Now the error logging is moved to it's own class, which synchronizes just the logging preventing this deadlock. I also made sure that all chunk messages are written out in chunks (they were being intermingled), and fixed the line numbers in the errors for csv & mysql when multiple threads are used.
This can be `static`.