Bug 1407917 - Simplify DDLogger string-logging functions - r?jwwang draft
authorGerald Squelart <gsquelart@mozilla.com>
Thu, 12 Oct 2017 17:51:41 +1100
changeset 678985 c50a72e22e8c859aec30407af66d54598b5d7cd0
parent 678967 8f1139a71ab06f0fd43eef84d6766e845dda9049
child 735491 29005a73afe6b67af3b165133b8245a33ab94767
push id84098
push usergsquelart@mozilla.com
push dateThu, 12 Oct 2017 06:59:15 +0000
reviewersjwwang
bugs1407917
milestone58.0a1
Bug 1407917 - Simplify DDLogger string-logging functions - r?jwwang Removed non-eager DDLogValue() functions, too confusing for not much value; users should use macros first anyway. Changed `EagerLogValue(..., const char (&aLiteral)[N])` to take `const char*`, it's cleaner and simpler. MozReview-Commit-ID: J7xcoPkp6Nf
dom/media/doctor/DecoderDoctorLogger.h
--- a/dom/media/doctor/DecoderDoctorLogger.h
+++ b/dom/media/doctor/DecoderDoctorLogger.h
@@ -93,66 +93,39 @@ public:
   {
     EagerLogValue(DDLoggedTypeTraits<Subject>::Name(),
                   aSubject,
                   aCategory,
                   aLabel,
                   Forward<Value>(aValue));
   }
 
-  // LogValue with a string literal, as they are not seen as `const char*` by
-  // Variant. Also, a literal doesn't have runtime costs, so it's cheap to call
-  // directly.
-  template<size_t N>
-  static void LogValue(const char* aSubjectTypeName,
-                       const void* aSubjectPointer,
-                       DDLogCategory aCategory,
-                       const char* aLabel,
-                       const char (&aLiteral)[N])
-  {
-    EagerLogValue(aSubjectTypeName,
-                  aSubjectPointer,
-                  aCategory,
-                  aLabel,
-                  static_cast<const char*>(aLiteral));
-  }
-
-  template<typename Subject, size_t N>
-  static void LogValue(const Subject* aSubject,
-                       DDLogCategory aCategory,
-                       const char* aLabel,
-                       const char (&aLiteral)[N])
-  {
-    EagerLogValue(
-      aSubject, aCategory, aLabel, static_cast<const char*>(aLiteral));
-  }
-
-  // Same as LogValue above, but needed to be seen by DDLOG... macros.
-  template<size_t N>
+  // EagerLogValue that can explicitly take strings, as the templated function
+  // above confuses Variant when forwarding string literals.
   static void EagerLogValue(const char* aSubjectTypeName,
                             const void* aSubjectPointer,
                             DDLogCategory aCategory,
                             const char* aLabel,
-                            const char (&aLiteral)[N])
+                            const char* aValue)
   {
-    EagerLogValue(aSubjectTypeName,
-                  aSubjectPointer,
-                  aCategory,
-                  aLabel,
-                  static_cast<const char*>(aLiteral));
+    Log(aSubjectTypeName,
+        aSubjectPointer,
+        aCategory,
+        aLabel,
+        DDLogValue{ aValue });
   }
 
-  template<typename Subject, size_t N>
+  template<typename Subject>
   static void EagerLogValue(const Subject* aSubject,
                             DDLogCategory aCategory,
                             const char* aLabel,
-                            const char (&aLiteral)[N])
+                            const char* aValue)
   {
     EagerLogValue(
-      aSubject, aCategory, aLabel, static_cast<const char*>(aLiteral));
+      DDLoggedTypeTraits<Subject>::Name(), aSubject, aCategory, aLabel, aValue);
   }
 
   template<typename... Args>
   static void EagerLogPrintf(const char* aSubjectTypeName,
                              const void* aSubjectPointer,
                              DDLogCategory aCategory,
                              const char* aLabel,
                              const char* aFormat,