Moved logger code into one function for lex