Logging cleanup: Check for null before method call