Title: [197214] trunk/Source/WTF
Revision
197214
Author
[email protected]
Date
2016-02-26 15:33:45 -0800 (Fri, 26 Feb 2016)

Log Message

Enhance logging: Add "always on" macros
https://bugs.webkit.org/show_bug.cgi?id=154498
<rdar://problem/24757759>

Patch by Keith Rollin <[email protected]> on 2016-02-26
Reviewed by Chris Dumez.

Add support for efficient always-on logging (logging that is available
in both debug and release builds). This is implemented in the form of
some new macros:

- LOG_ALWAYS: Always log information-level statements.
- LOG_ALWAYS_ERROR: Always log error-level statements. These can be
  filtered out of the normal logging so that they can be found more
  easily.

In cases where there is no efficient underlying facility for it to
utilize, LOG_ALWAYS_ERROR is redirected to WTFReportError as a backup
mechanism. LOG_ALWAYS is not given a similar treatment so that we
don't overwhelm other logging systems that aren't prepared for "always
on" logging.

* wtf/Assertions.h:
* wtf/Platform.h:

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (197213 => 197214)


--- trunk/Source/WTF/ChangeLog	2016-02-26 23:26:36 UTC (rev 197213)
+++ trunk/Source/WTF/ChangeLog	2016-02-26 23:33:45 UTC (rev 197214)
@@ -1,3 +1,29 @@
+2016-02-26  Keith Rollin  <[email protected]>
+
+        Enhance logging: Add "always on" macros
+        https://bugs.webkit.org/show_bug.cgi?id=154498
+        <rdar://problem/24757759>
+
+        Reviewed by Chris Dumez.
+
+        Add support for efficient always-on logging (logging that is available
+        in both debug and release builds). This is implemented in the form of
+        some new macros:
+
+        - LOG_ALWAYS: Always log information-level statements.
+        - LOG_ALWAYS_ERROR: Always log error-level statements. These can be
+          filtered out of the normal logging so that they can be found more
+          easily.
+
+        In cases where there is no efficient underlying facility for it to
+        utilize, LOG_ALWAYS_ERROR is redirected to WTFReportError as a backup
+        mechanism. LOG_ALWAYS is not given a similar treatment so that we
+        don't overwhelm other logging systems that aren't prepared for "always
+        on" logging.
+
+        * wtf/Assertions.h:
+        * wtf/Platform.h:
+
 2016-02-26  Anders Carlsson  <[email protected]>
 
         Add WTF::OptionSet and use it for the website data types enum

Modified: trunk/Source/WTF/wtf/Assertions.h (197213 => 197214)


--- trunk/Source/WTF/wtf/Assertions.h	2016-02-26 23:26:36 UTC (rev 197213)
+++ trunk/Source/WTF/wtf/Assertions.h	2016-02-26 23:33:45 UTC (rev 197214)
@@ -34,8 +34,9 @@
    Note, this file uses many GCC extensions, but it should be compatible with
    C, Objective C, C++, and Objective C++.
 
-   For non-debug builds, everything is disabled by default.
-   Defining any of the symbols explicitly prevents this from having any effect.
+   For non-debug builds, everything is disabled by default except for "always
+   on" logging. Defining any of the symbols explicitly prevents this from
+   having any effect.
 */
 
 #include <inttypes.h>
@@ -44,6 +45,10 @@
 #include <stddef.h>
 #include <wtf/ExportMacros.h>
 
+#if USE(OS_LOG)
+#include <os/log.h>
+#endif
+
 #ifdef NDEBUG
 /* Disable ASSERT* macros in release mode. */
 #define ASSERTIONS_DISABLED_DEFAULT 1
@@ -79,6 +84,10 @@
 #define LOG_DISABLED ASSERTIONS_DISABLED_DEFAULT
 #endif
 
+#ifndef LOG_ALWAYS_DISABLED
+#define LOG_ALWAYS_DISABLED !(USE(OS_LOG))
+#endif
+
 #if COMPILER(GCC_OR_CLANG)
 #define WTF_PRETTY_FUNCTION __PRETTY_FUNCTION__
 #else
@@ -371,6 +380,18 @@
 #define LOG_VERBOSE(channel, ...) WTFLogVerbose(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, &JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_PREFIX, channel), __VA_ARGS__)
 #endif
 
+/* LOG_ALWAYS */
+
+#define WTF_LOGGING_PREFIX "#WK: "
+#if LOG_ALWAYS_DISABLED
+#define LOG_ALWAYS(format, ...)       ((void)0)
+#define LOG_ALWAYS_ERROR(format, ...) WTFReportError(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, format, ##__VA_ARGS__)
+#else
+#define WTF_LOG_DEFAULT OS_LOG_DEFAULT
+#define LOG_ALWAYS(format, ...)       os_log(WTF_LOG_DEFAULT, WTF_LOGGING_PREFIX format, ##__VA_ARGS__)
+#define LOG_ALWAYS_ERROR(format, ...) os_log_error(WTF_LOG_DEFAULT, WTF_LOGGING_PREFIX format, ##__VA_ARGS__)
+#endif
+
 /* RELEASE_ASSERT */
 
 #if ASSERT_DISABLED

Modified: trunk/Source/WTF/wtf/Platform.h (197213 => 197214)


--- trunk/Source/WTF/wtf/Platform.h	2016-02-26 23:26:36 UTC (rev 197213)
+++ trunk/Source/WTF/wtf/Platform.h	2016-02-26 23:33:45 UTC (rev 197214)
@@ -1133,4 +1133,8 @@
 #define HAVE_COREANIMATION_FENCES 1
 #endif
 
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000)
+#define USE_OS_LOG 1
+#endif
+
 #endif /* WTF_Platform_h */
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to