OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_LOGGING_H_ | 5 #ifndef BASE_LOGGING_H_ |
6 #define BASE_LOGGING_H_ | 6 #define BASE_LOGGING_H_ |
7 | 7 |
8 #include <cassert> | 8 #include <cassert> |
9 #include <string> | 9 #include <string> |
10 #include <cstring> | 10 #include <cstring> |
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
942 // | 942 // |
943 // The implementation of this macro is controlled by NOTIMPLEMENTED_POLICY: | 943 // The implementation of this macro is controlled by NOTIMPLEMENTED_POLICY: |
944 // 0 -- Do nothing (stripped by compiler) | 944 // 0 -- Do nothing (stripped by compiler) |
945 // 1 -- Warn at compile time | 945 // 1 -- Warn at compile time |
946 // 2 -- Fail at compile time | 946 // 2 -- Fail at compile time |
947 // 3 -- Fail at runtime (DCHECK) | 947 // 3 -- Fail at runtime (DCHECK) |
948 // 4 -- [default] LOG(ERROR) at runtime | 948 // 4 -- [default] LOG(ERROR) at runtime |
949 // 5 -- LOG(ERROR) at runtime, only once per call-site | 949 // 5 -- LOG(ERROR) at runtime, only once per call-site |
950 | 950 |
951 #ifndef NOTIMPLEMENTED_POLICY | 951 #ifndef NOTIMPLEMENTED_POLICY |
| 952 #if defined(OS_ANDROID) && defined(OFFICIAL_BUILD) |
| 953 #define NOTIMPLEMENTED_POLICY 0 |
| 954 #else |
952 // Select default policy: LOG(ERROR) | 955 // Select default policy: LOG(ERROR) |
953 #define NOTIMPLEMENTED_POLICY 4 | 956 #define NOTIMPLEMENTED_POLICY 4 |
954 #endif | 957 #endif |
| 958 #endif |
955 | 959 |
956 #if defined(COMPILER_GCC) | 960 #if defined(COMPILER_GCC) |
957 // On Linux, with GCC, we can use __PRETTY_FUNCTION__ to get the demangled name | 961 // On Linux, with GCC, we can use __PRETTY_FUNCTION__ to get the demangled name |
958 // of the current function in the NOTIMPLEMENTED message. | 962 // of the current function in the NOTIMPLEMENTED message. |
959 #define NOTIMPLEMENTED_MSG "Not implemented reached in " << __PRETTY_FUNCTION__ | 963 #define NOTIMPLEMENTED_MSG "Not implemented reached in " << __PRETTY_FUNCTION__ |
960 #else | 964 #else |
961 #define NOTIMPLEMENTED_MSG "NOT IMPLEMENTED" | 965 #define NOTIMPLEMENTED_MSG "NOT IMPLEMENTED" |
962 #endif | 966 #endif |
963 | 967 |
964 #if NOTIMPLEMENTED_POLICY == 0 | 968 #if NOTIMPLEMENTED_POLICY == 0 |
965 #define NOTIMPLEMENTED() EAT_STREAM_PARAMETERS | 969 #define NOTIMPLEMENTED() EAT_STREAM_PARAMETERS |
966 #elif NOTIMPLEMENTED_POLICY == 1 | 970 #elif NOTIMPLEMENTED_POLICY == 1 |
967 // TODO, figure out how to generate a warning | 971 // TODO, figure out how to generate a warning |
968 #define NOTIMPLEMENTED() COMPILE_ASSERT(false, NOT_IMPLEMENTED) | 972 #define NOTIMPLEMENTED() COMPILE_ASSERT(false, NOT_IMPLEMENTED) |
969 #elif NOTIMPLEMENTED_POLICY == 2 | 973 #elif NOTIMPLEMENTED_POLICY == 2 |
970 #define NOTIMPLEMENTED() COMPILE_ASSERT(false, NOT_IMPLEMENTED) | 974 #define NOTIMPLEMENTED() COMPILE_ASSERT(false, NOT_IMPLEMENTED) |
971 #elif NOTIMPLEMENTED_POLICY == 3 | 975 #elif NOTIMPLEMENTED_POLICY == 3 |
972 #define NOTIMPLEMENTED() NOTREACHED() | 976 #define NOTIMPLEMENTED() NOTREACHED() |
973 #elif NOTIMPLEMENTED_POLICY == 4 | 977 #elif NOTIMPLEMENTED_POLICY == 4 |
974 #define NOTIMPLEMENTED() LOG(ERROR) << NOTIMPLEMENTED_MSG | 978 #define NOTIMPLEMENTED() LOG(ERROR) << NOTIMPLEMENTED_MSG |
975 #elif NOTIMPLEMENTED_POLICY == 5 | 979 #elif NOTIMPLEMENTED_POLICY == 5 |
976 #define NOTIMPLEMENTED() do {\ | 980 #define NOTIMPLEMENTED() do {\ |
977 static int count = 0;\ | 981 static int count = 0;\ |
978 LOG_IF(ERROR, 0 == count++) << NOTIMPLEMENTED_MSG;\ | 982 LOG_IF(ERROR, 0 == count++) << NOTIMPLEMENTED_MSG;\ |
979 } while(0) | 983 } while(0) |
980 #endif | 984 #endif |
981 | 985 |
982 #endif // BASE_LOGGING_H_ | 986 #endif // BASE_LOGGING_H_ |
OLD | NEW |