Fix copyright lines
[folly.git] / folly / experimental / logging / LogStreamProcessor.cpp
index 2415ed4acf674bdb3cbb461640c1a1a2f3d50239..b9fd164c57ab6f641f2e19e070314649b3af3f05 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2004-present Facebook, Inc.
+ * Copyright 2017-present Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -52,20 +52,6 @@ LogStreamProcessor::LogStreamProcessor(
           INTERNAL,
           std::string()) {}
 
-LogStreamProcessor::LogStreamProcessor(
-    XlogFileScopeInfo* fileScopeInfo,
-    LogLevel level,
-    folly::StringPiece filename,
-    unsigned int lineNumber,
-    AppendType) noexcept
-    : LogStreamProcessor(
-          fileScopeInfo,
-          level,
-          filename,
-          lineNumber,
-          INTERNAL,
-          std::string()) {}
-
 LogStreamProcessor::LogStreamProcessor(
     const LogCategory* category,
     LogLevel level,
@@ -90,14 +76,7 @@ LogCategory* getXlogCategory(
   }
   return categoryInfo->getCategory(&xlog_detail::xlogFileScopeInfo);
 }
-
-LogCategory* getXlogCategory(XlogFileScopeInfo* fileScopeInfo) {
-  // By the time a LogStreamProcessor is created, the XlogFileScopeInfo object
-  // should have already been initialized to perform the log level check.
-  // Therefore we never need to check if it is initialized here.
-  return fileScopeInfo->category;
-}
-}
+} // namespace
 
 /**
  * Construct a LogStreamProcessor from an XlogCategoryInfo.
@@ -125,12 +104,28 @@ LogStreamProcessor::LogStreamProcessor(
       message_{std::move(msg)},
       stream_{this} {}
 
+#ifdef __INCLUDE_LEVEL__
+namespace {
+LogCategory* getXlogCategory(XlogFileScopeInfo* fileScopeInfo) {
+  // By the time a LogStreamProcessor is created, the XlogFileScopeInfo object
+  // should have already been initialized to perform the log level check.
+  // Therefore we never need to check if it is initialized here.
+  return fileScopeInfo->category;
+}
+} // namespace
+
 /**
  * Construct a LogStreamProcessor from an XlogFileScopeInfo.
  *
  * We intentionally define this in LogStreamProcessor.cpp instead of
  * LogStreamProcessor.h to avoid having it inlined at every XLOG() call site,
  * to reduce the emitted code size.
+ *
+ * This is only defined if __INCLUDE_LEVEL__ is available.  The
+ * XlogFileScopeInfo APIs are only invoked if we can use __INCLUDE_LEVEL__ to
+ * tell that an XLOG() statement occurs in a non-header file.  For compilers
+ * that do not support __INCLUDE_LEVEL__, the category information is always
+ * passed in as XlogCategoryInfo<true> rather than as XlogFileScopeInfo.
  */
 LogStreamProcessor::LogStreamProcessor(
     XlogFileScopeInfo* fileScopeInfo,
@@ -146,6 +141,21 @@ LogStreamProcessor::LogStreamProcessor(
       message_{std::move(msg)},
       stream_{this} {}
 
+LogStreamProcessor::LogStreamProcessor(
+    XlogFileScopeInfo* fileScopeInfo,
+    LogLevel level,
+    folly::StringPiece filename,
+    unsigned int lineNumber,
+    AppendType) noexcept
+    : LogStreamProcessor(
+          fileScopeInfo,
+          level,
+          filename,
+          lineNumber,
+          INTERNAL,
+          std::string()) {}
+#endif
+
 /*
  * We intentionally define the LogStreamProcessor destructor in
  * LogStreamProcessor.cpp instead of LogStreamProcessor.h to avoid having it
@@ -209,4 +219,4 @@ void logDisabledHelper(std::integral_constant<bool, true>) noexcept {
   // builds) or DFATAL (in debug builds).
   abort();
 }
-}
+} // namespace folly