Fix undefined error and format code

Moved some variable defines around to fix undefined errors.
Formatted code to follow editorconfig.
Merge pull request #19 from truckingsim/bugfix-log-error

Fix undefined error and format code