Filter log messages before writing to file

Also fix a platform detection bug...
Use context manager to close log file
Light refactoring of bob.nxc
Move bt_log_number to the top
Add missing argument to strcat in bt_log_number
Merge pull request #1 from afflux/refactored

Refactored parts of the main loop