code: def format_argument(self, arg):
          
          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')
docs: Format a Message argument to a string