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 | |
955 // Select default policy: LOG(ERROR) | 952 // Select default policy: LOG(ERROR) |
956 #define NOTIMPLEMENTED_POLICY 4 | 953 #define NOTIMPLEMENTED_POLICY 4 |
957 #endif | 954 #endif |
958 #endif | |
959 | 955 |
960 #if defined(COMPILER_GCC) | 956 #if defined(COMPILER_GCC) |
961 // On Linux, with GCC, we can use __PRETTY_FUNCTION__ to get the demangled name | 957 // On Linux, with GCC, we can use __PRETTY_FUNCTION__ to get the demangled name |
962 // of the current function in the NOTIMPLEMENTED message. | 958 // of the current function in the NOTIMPLEMENTED message. |
963 #define NOTIMPLEMENTED_MSG "Not implemented reached in " << __PRETTY_FUNCTION__ | 959 #define NOTIMPLEMENTED_MSG "Not implemented reached in " << __PRETTY_FUNCTION__ |
964 #else | 960 #else |
965 #define NOTIMPLEMENTED_MSG "NOT IMPLEMENTED" | 961 #define NOTIMPLEMENTED_MSG "NOT IMPLEMENTED" |
966 #endif | 962 #endif |
967 | 963 |
968 #if NOTIMPLEMENTED_POLICY == 0 | 964 #if NOTIMPLEMENTED_POLICY == 0 |
969 #define NOTIMPLEMENTED() EAT_STREAM_PARAMETERS | 965 #define NOTIMPLEMENTED() EAT_STREAM_PARAMETERS |
970 #elif NOTIMPLEMENTED_POLICY == 1 | 966 #elif NOTIMPLEMENTED_POLICY == 1 |
971 // TODO, figure out how to generate a warning | 967 // TODO, figure out how to generate a warning |
972 #define NOTIMPLEMENTED() COMPILE_ASSERT(false, NOT_IMPLEMENTED) | 968 #define NOTIMPLEMENTED() COMPILE_ASSERT(false, NOT_IMPLEMENTED) |
973 #elif NOTIMPLEMENTED_POLICY == 2 | 969 #elif NOTIMPLEMENTED_POLICY == 2 |
974 #define NOTIMPLEMENTED() COMPILE_ASSERT(false, NOT_IMPLEMENTED) | 970 #define NOTIMPLEMENTED() COMPILE_ASSERT(false, NOT_IMPLEMENTED) |
975 #elif NOTIMPLEMENTED_POLICY == 3 | 971 #elif NOTIMPLEMENTED_POLICY == 3 |
976 #define NOTIMPLEMENTED() NOTREACHED() | 972 #define NOTIMPLEMENTED() NOTREACHED() |
977 #elif NOTIMPLEMENTED_POLICY == 4 | 973 #elif NOTIMPLEMENTED_POLICY == 4 |
978 #define NOTIMPLEMENTED() LOG(ERROR) << NOTIMPLEMENTED_MSG | 974 #define NOTIMPLEMENTED() LOG(ERROR) << NOTIMPLEMENTED_MSG |
979 #elif NOTIMPLEMENTED_POLICY == 5 | 975 #elif NOTIMPLEMENTED_POLICY == 5 |
980 #define NOTIMPLEMENTED() do {\ | 976 #define NOTIMPLEMENTED() do {\ |
981 static int count = 0;\ | 977 static int count = 0;\ |
982 LOG_IF(ERROR, 0 == count++) << NOTIMPLEMENTED_MSG;\ | 978 LOG_IF(ERROR, 0 == count++) << NOTIMPLEMENTED_MSG;\ |
983 } while(0) | 979 } while(0) |
984 #endif | 980 #endif |
985 | 981 |
986 #endif // BASE_LOGGING_H_ | 982 #endif // BASE_LOGGING_H_ |
OLD | NEW |