| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 // Lastly, PLOG(sev, err) is an alias for LOG_ERR_EX. | 44 // Lastly, PLOG(sev, err) is an alias for LOG_ERR_EX. |
| 45 | 45 |
| 46 #ifndef WEBRTC_BASE_LOGGING_H_ | 46 #ifndef WEBRTC_BASE_LOGGING_H_ |
| 47 #define WEBRTC_BASE_LOGGING_H_ | 47 #define WEBRTC_BASE_LOGGING_H_ |
| 48 | 48 |
| 49 #include <list> | 49 #include <list> |
| 50 #include <sstream> | 50 #include <sstream> |
| 51 #include <string> | 51 #include <string> |
| 52 #include <utility> | 52 #include <utility> |
| 53 | 53 |
| 54 #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) |
| 55 #include <CoreServices/CoreServices.h> |
| 56 #endif |
| 57 |
| 54 #include "webrtc/base/basictypes.h" | 58 #include "webrtc/base/basictypes.h" |
| 55 #include "webrtc/base/constructormagic.h" | 59 #include "webrtc/base/constructormagic.h" |
| 56 #include "webrtc/base/thread_annotations.h" | 60 #include "webrtc/base/thread_annotations.h" |
| 57 | 61 |
| 58 namespace rtc { | 62 namespace rtc { |
| 59 | 63 |
| 60 /////////////////////////////////////////////////////////////////////////////// | 64 /////////////////////////////////////////////////////////////////////////////// |
| 61 // ConstantLabel can be used to easily generate string names from constant | 65 // ConstantLabel can be used to easily generate string names from constant |
| 62 // values. This can be useful for logging descriptive names of error messages. | 66 // values. This can be useful for logging descriptive names of error messages. |
| 63 // Usage: | 67 // Usage: |
| 64 // const ConstantLabel LIBRARY_ERRORS[] = { | 68 // const ConstantLabel LIBRARY_ERRORS[] = { |
| 65 // KLABEL(SOME_ERROR), | 69 // KLABEL(SOME_ERROR), |
| 66 // KLABEL(SOME_OTHER_ERROR), | 70 // KLABEL(SOME_OTHER_ERROR), |
| 67 // ... | 71 // ... |
| 68 // LASTLABEL | 72 // LASTLABEL |
| 69 // } | 73 // } |
| 70 // | 74 // |
| 71 // int err = LibraryFunc(); | 75 // int err = LibraryFunc(); |
| 72 // LOG(LS_ERROR) << "LibraryFunc returned: " | 76 // LOG(LS_ERROR) << "LibraryFunc returned: " |
| 73 // << ErrorName(err, LIBRARY_ERRORS); | 77 // << ErrorName(err, LIBRARY_ERRORS); |
| 74 | 78 |
| 75 struct ConstantLabel { int value; const char * label; }; | 79 struct ConstantLabel { int value; const char * label; }; |
| 76 #define KLABEL(x) { x, #x } | 80 #define KLABEL(x) { x, #x } |
| 77 #define TLABEL(x, y) { x, y } | 81 #define TLABEL(x, y) { x, y } |
| 78 #define LASTLABEL { 0, 0 } | 82 #define LASTLABEL { 0, 0 } |
| 79 | 83 |
| 80 const char* FindLabel(int value, const ConstantLabel entries[]); | 84 const char* FindLabel(int value, const ConstantLabel entries[]); |
| 81 std::string ErrorName(int err, const ConstantLabel* err_table); | 85 std::string ErrorName(int err, const ConstantLabel* err_table); |
| 82 | 86 |
| 87 #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) |
| 88 // Returns a UTF8 description from an OS X Status error. |
| 89 std::string DescriptionFromOSStatus(OSStatus err); |
| 90 #endif |
| 91 |
| 83 ////////////////////////////////////////////////////////////////////// | 92 ////////////////////////////////////////////////////////////////////// |
| 84 | 93 |
| 85 // Note that the non-standard LoggingSeverity aliases exist because they are | 94 // Note that the non-standard LoggingSeverity aliases exist because they are |
| 86 // still in broad use. The meanings of the levels are: | 95 // still in broad use. The meanings of the levels are: |
| 87 // LS_SENSITIVE: Information which should only be logged with the consent | 96 // LS_SENSITIVE: Information which should only be logged with the consent |
| 88 // of the user, due to privacy concerns. | 97 // of the user, due to privacy concerns. |
| 89 // LS_VERBOSE: This level is for data which we do not want to appear in the | 98 // LS_VERBOSE: This level is for data which we do not want to appear in the |
| 90 // normal debug log, but should appear in diagnostic logs. | 99 // normal debug log, but should appear in diagnostic logs. |
| 91 // LS_INFO: Chatty level used in debugging for all sorts of things, the default | 100 // LS_INFO: Chatty level used in debugging for all sorts of things, the default |
| 92 // in debug builds. | 101 // in debug builds. |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 #define PLOG(sev, err) \ | 356 #define PLOG(sev, err) \ |
| 348 LOG_ERR_EX(sev, err) | 357 LOG_ERR_EX(sev, err) |
| 349 | 358 |
| 350 // TODO(?): Add an "assert" wrapper that logs in the same manner. | 359 // TODO(?): Add an "assert" wrapper that logs in the same manner. |
| 351 | 360 |
| 352 #endif // LOG | 361 #endif // LOG |
| 353 | 362 |
| 354 } // namespace rtc | 363 } // namespace rtc |
| 355 | 364 |
| 356 #endif // WEBRTC_BASE_LOGGING_H_ | 365 #endif // WEBRTC_BASE_LOGGING_H_ |
| OLD | NEW |