logging: add support for streaming operators
authorAdam Simpkins <simpkins@fb.com>
Tue, 13 Jun 2017 01:33:05 +0000 (18:33 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 13 Jun 2017 01:38:15 +0000 (18:38 -0700)
commitdc2c2837d095c9d3a5407e939a88b982ba37858a
tree93f9451e4a457ed8d40b042ecf57c627071a4138
parente9c1c0434713e921c98288e932c05f228a734886
logging: add support for streaming operators

Summary:
Update the logging library so that FB_LOG() and FB_LOGF() also accept
streaming style arguments:

  FB_LOG(logger) << "logs can be written like this now: " << 1234;
  FB_LOG(logger, "both styles can be used") << " together";
  FB_LOGF(logger, "test: {}, {}", 1234, 5678) << " and with FB_LOGF() too";

Streaming support does make the upcoming XLOG() macros more complicated to
implement, since the macro has to expand to a single ternary `?` expression.
However I was able to come up with a solution that works and has minimal
overhead.

Reviewed By: wez

Differential Revision: D5082979

fbshipit-source-id: 11734e39c02ad28aceb44bbfbd137d781caa30cf
13 files changed:
CMakeLists.txt
folly/Makefile.am
folly/experimental/logging/LogCategory.cpp
folly/experimental/logging/LogCategory.h
folly/experimental/logging/LogStream.cpp [new file with mode: 0644]
folly/experimental/logging/LogStream.h [new file with mode: 0644]
folly/experimental/logging/LogStreamProcessor.cpp [new file with mode: 0644]
folly/experimental/logging/LogStreamProcessor.h [new file with mode: 0644]
folly/experimental/logging/Logger.cpp
folly/experimental/logging/Logger.h
folly/experimental/logging/Makefile.am
folly/experimental/logging/test/LogStreamTest.cpp [new file with mode: 0644]
folly/experimental/logging/test/LoggerTest.cpp