You are tasked with creating a function that attempts to perform a division operation and handles any exceptions that may arise. The function should log the error message if an exception occurs and return a specific value based on the type of exception encountered.
safe_divide(numerator, denominator) that takes two parameters: numerator (int) and denominator (int).ZeroDivisionError occurs, log 'Cannot divide by zero' and return None.TypeError occurs (e.g., if the inputs are not integers), log 'Invalid input type' and return None.None.Example 1:
Input: safe_divide(10, 2)
Output: 5.0
Example 2:
Input: safe_divide(10, 0)
Output: None
// Log: 'Cannot divide by zero'
Example 3:
Input: safe_divide(10, 'a')
Output: None
// Log: 'Invalid input type'