<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def format_argument(self, arg):
 """Format a Message argument to a string"""

        if isinstance(arg, float):
            return repr(arg)
        elif isinstance(arg, bool):
            return str(int(arg))
        else:
            try:
                return str(arg)
            except UnicodeEncodeError:
                # unicode characters will break the str cast, so
                # try to encode to ascii and replace the offending characters
                # with a '?' character
                logger.error("Error casting message argument to str! "
                             "Trying to encode argument to ascii.")
                if not isinstance(arg, unicode):
                    arg = arg.decode('utf-8')
                return arg.encode('ascii', 'replace')