Index: third_party/grpc/src/core/support/log_android.c |
diff --git a/third_party/WebKit/Source/build/win/Precompile.h b/third_party/grpc/src/core/support/log_android.c |
similarity index 53% |
copy from third_party/WebKit/Source/build/win/Precompile.h |
copy to third_party/grpc/src/core/support/log_android.c |
index 8a0ff29c353fc1d30c92d27f369d7c422a579bc8..5d0c7d820d82d227b2f660d01868694b43bb0967 100644 |
--- a/third_party/WebKit/Source/build/win/Precompile.h |
+++ b/third_party/grpc/src/core/support/log_android.c |
@@ -1,5 +1,7 @@ |
/* |
- * Copyright (C) 2012 Google Inc. All rights reserved. |
+ * |
+ * Copyright 2015, Google Inc. |
+ * All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions are |
@@ -26,43 +28,60 @@ |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
- */ |
- |
-/* |
- * Precompiled header for WebKit when built on Windows using |
- * GYP-generated project files. Not used by other build |
- * configurations. |
* |
- * Using precompiled headers speeds the build up significantly. On a |
- * fast machine (HP Z600, 12 GB of RAM), an ~18% decrease in full |
- * build time was measured. |
*/ |
-#if defined(WinPrecompile_h_) |
-#error You shouldn't include the precompiled header file more than once. |
-#endif |
+#include <grpc/support/port_platform.h> |
-#define WinPrecompile_h_ |
+#ifdef GPR_ANDROID |
-#define _USE_MATH_DEFINES // Make math.h behave like other platforms. |
- |
-#include <Windows.h> |
- |
-#include <errno.h> |
-#include <fcntl.h> |
-#include <limits.h> |
-#include <math.h> |
-#include <stdarg.h> |
-#include <stddef.h> |
+#include <grpc/support/log.h> |
+#include <grpc/support/time.h> |
#include <stdio.h> |
-#include <stdlib.h> |
+#include <stdarg.h> |
#include <string.h> |
-#include <time.h> |
+#include <android/log.h> |
+ |
+static android_LogPriority severity_to_log_priority(gpr_log_severity severity) { |
+ switch (severity) { |
+ case GPR_LOG_SEVERITY_DEBUG: |
+ return ANDROID_LOG_DEBUG; |
+ case GPR_LOG_SEVERITY_INFO: |
+ return ANDROID_LOG_INFO; |
+ case GPR_LOG_SEVERITY_ERROR: |
+ return ANDROID_LOG_ERROR; |
+ } |
+ return ANDROID_LOG_DEFAULT; |
+} |
+ |
+void gpr_log(const char *file, int line, gpr_log_severity severity, |
+ const char *format, ...) { |
+ char *message = NULL; |
+ va_list args; |
+ va_start(args, format); |
+ vasprintf(&message, format, args); |
+ va_end(args); |
+ gpr_log_message(file, line, severity, message); |
+ free(message); |
+} |
+ |
+void gpr_default_log(gpr_log_func_args *args) { |
+ char *final_slash; |
+ const char *display_file; |
+ char *output = NULL; |
+ |
+ final_slash = strrchr(args->file, '/'); |
+ if (final_slash == NULL) |
+ display_file = args->file; |
+ else |
+ display_file = final_slash + 1; |
+ |
+ asprintf(&output, "%s:%d] %s", display_file, args->line, args->message); |
+ |
+ __android_log_write(severity_to_log_priority(args->severity), "GRPC", output); |
+ |
+ /* allocated by asprintf => use free, not gpr_free */ |
+ free(output); |
+} |
-#include <algorithm> |
-#include <ciso646> |
-#include <cmath> |
-#include <cstddef> |
-#include <limits> |
-#include <string> |
-#include <utility> |
+#endif /* GPR_ANDROID */ |