Use proper logging system
For now we just use cout/cerr for logging and copy output to log file. This approach has drawbacks:
- Garbaged output, when logging from different threads in the same time.
- No way to filter output.
I suggest to do these things:
- Implement a threadsafe logger (probably we can use mutex to lock cerr).
- Impelement debug levels. In this case we will may to filter messages depending on their severity.
- Use ANSI colors to highlight messages depending on their severity.