Use the "Verify Solution" button to get AI feedback on your C++ code.
You are tasked with fixing and enhancing a Logger class in C++. The existing implementation uses a raw char* to store log messages, which are dynamically allocated. Currently, the class exhibits classic memory management issues, specifically related to object copying and assignment.
Your goal is to:
Implement a deep copy mechanism for the Logger class.
Ensure proper resource cleanup to prevent memory leaks or double-free errors.
Adhere to the Rule of Three/Five by correctly defining the copy constructor, copy assignment operator, and destructor (and potentially move constructor/assignment for C++11 and later, though not strictly required for this specific problem unless you choose to implement it as an optimization).