added support for logging in different situations