logc: add signal masking
This ensures signal safety when outputting logs. It prevents output mixing when logging from signal handlers.
This works by masking all signals when we start generating log output. This means that we don't get any signals until we truly generate the output and thus when signal handlers is called it is safe to generate output.
Implements #3 (closed).