moved logging lock failure in seperate function

to seperate it away from main code