import logging
import re
from typing import Any, Union

# Configure logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')

def is_within_range(value: Union[int, float], min_value: Union[int, float], max_value: Union[int, float]) -> bool:
    """
    Checks if a value is within a specified range (inclusive).

    Args:
        value: The value to check.
        min_value: The minimum allowed value.
        max_value: The maximum allowed value.

    Returns:
        True if the value is within the range, False otherwise.
    """
    try:
        if not isinstance(value, (int, float)) or not isinstance(min_value, (int, float)) or not isinstance(max_value, (int, float)):
            raise TypeError("All arguments must be numeric (int or float).")
        if min_value > max_value:
            raise ValueError("Minimum value cannot be greater than maximum value.")
        return min_value <= value <= max_value
    except TypeError as e:
        logging.error(f"Type error in is_within_range: {e}")
        return False
    except ValueError as e:
        logging.error(f"Value error in is_within_range: {e}")
        return False
    except Exception as e:
        logging.exception(f"An unexpected error occurred: {e}")
        return False


def is_valid_email(email: str) -> bool:
    """
    Checks if a string is a valid email address using a regular expression.

    Args:
        email: The string to check.

    Returns:
        True if the string is a valid email address, False otherwise.
    """
    try:
        if not isinstance(email, str):
            raise TypeError("Email must be a string.")

        # A simple regex for email validation
        email_regex = r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"
        return re.match(email_regex, email) is not None
    except TypeError as e:
        logging.error(f"Type error in is_valid_email: {e}")
        return False
    except Exception as e:
        logging.exception(f"An unexpected error occurred: {e}")
        return False

def is_not_empty_string(text: str) -> bool:
    """
    Checks if a string is not empty after removing leading/trailing whitespaces.

    Args:
        text: The string to check.

    Returns:
        True if the string is not empty, False otherwise.
    """
    try:
        if not isinstance(text, str):
            raise TypeError("Input must be a string.")
        return len(text.strip()) > 0
    except TypeError as e:
        logging.error(f"Type error in is_not_empty_string: {e}")
        return False
    except Exception as e:
        logging.exception(f"An unexpected error occurred: {e}")
        return False


if __name__ == '__main__':
    # Example usage
    print(f"Is 5 within range 1-10? {is_within_range(5, 1, 10)}")
    print(f"Is 15 within range 1-10? {is_within_range(15, 1, 10)}")
    print(f"Is abc@example.com a valid email? {is_valid_email('abc@example.com')}")
    print(f"Is invalid_email a valid email? {is_valid_email('invalid_email')}")
    print(f"Is '   ' a non-empty string? {is_not_empty_string('   ')}")
    print(f"Is 'test' a non-empty string? {is_not_empty_string('test')}")