THRIFT-926. cpp: remove auto-stringification in TLogging.h
authorDavid Reiss <dreiss@apache.org>
Wed, 6 Oct 2010 17:10:53 +0000 (17:10 +0000)
committerDavid Reiss <dreiss@apache.org>
Wed, 6 Oct 2010 17:10:53 +0000 (17:10 +0000)
commit46e4f252dcc09b40f71635aaeb80476635aa8076
treefbe79fdf3dc65c73c87dc79cd850de06a6ad7220
parent89a12942d2fd53a3caf269f601134bd392fbf333
THRIFT-926. cpp: remove auto-stringification in TLogging.h

The T_DEBUG* and T_ERROR* macros used preprocessor stringification to
stringify the format string argument.  This was weird and unintuitive.

With the old behavior:

- Quotes surrounding the format string were included in the message:
  T_DEBUG("this is a test") --> expanded to  "\"this is a test\""

- Backslashes in the string are escaped so they print literally:
  T_DEBUG("foo\nbar")       --> expanded to  "\"foo\\nbar\""

- Standard fixed-width integer format macros don't work:
  T_DEBUG("x: %" PRIi64, x) --> expanded to  "\"x: %\" PRIi64"

The last item is particularly problematic, since it prevents 64-bit
values from being logged portably.

With the new code, the following will no longer compile:

  T_DEBUG(this is my log message: %d, 5)

I don't think that is a bad thing, though.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005170 13f79535-47bb-0310-9956-ffa450edef68
lib/cpp/src/TLogging.h