def FormatLogArgument(s):
 MAX_LEN = 256
 if isinstance(s, unicode):
  s = s.encode('utf-8')
 else:
  s = str(s)
 if (len(s) <= MAX_LEN):
  return s
 return ('%s...[%d bytes truncated]' % (s[:MAX_LEN], (len(s) - MAX_LEN)))

def FormatLogArgument ( s ) : MAX_LEN = 256 if isinstance ( s , unicode ) : s = s . encode ( 'utf-8' ) else : s = str ( s ) if ( len ( s ) <= MAX_LEN ) : return s return ( '%s...[%d bytes truncated]' % ( s [ : MAX_LEN ] , ( len ( s ) - MAX_LEN ) ) )
format "s" in a human-readable way for logging by truncating it to at most 256 characters .