Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROME_BROWSER_SYNC_FILE_SYSTEM_LOGGER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_LOGGER_H_ |
| 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_LOGGER_H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_LOGGER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/location.h" | |
| 12 #include "base/logging.h" | |
| 11 #include "chrome/browser/google_apis/event_logger.h" | 13 #include "chrome/browser/google_apis/event_logger.h" |
| 12 | 14 |
| 13 namespace sync_file_system { | 15 namespace sync_file_system { |
| 14 // Originally wanted to use 'logging' here, but it conflicts with | 16 // Originally wanted to use 'logging' here, but it conflicts with |
| 15 // base/logging.h, and breaks DCHECK() and friends. | 17 // base/logging.h, and breaks DCHECK() and friends. |
| 16 namespace util { | 18 namespace util { |
| 17 | 19 |
| 20 // Resets the log. | |
| 21 void ClearLog(); | |
| 22 | |
| 18 // Logs a message using printf format. | 23 // Logs a message using printf format. |
| 19 // This function can be called from any thread. | 24 // This function can be called from any thread. |
| 20 void Log(const char* format, ...) PRINTF_FORMAT(1, 2); | 25 void Log(tracked_objects::Location location, |
| 26 logging::LogSeverity level, | |
| 27 const char* format, | |
| 28 ...) | |
| 29 PRINTF_FORMAT(3, 4); | |
| 30 | |
| 31 // Macros to keep the file and line location of the original Log calls. | |
| 32 // Unfortunately the second version with no args seems to be needed to keep the | |
| 33 // compiler happy. | |
| 34 #define SYNCFS_LOG_WITH_ARGS(severity, format, ...) \ | |
| 35 sync_file_system::util::Log( \ | |
| 36 FROM_HERE, logging::LOG_##severity, format, __VA_ARGS__); | |
| 37 #define SYNCFS_LOG_WITH_NO_ARGS(severity, message) \ | |
| 38 sync_file_system::util::Log(FROM_HERE, logging::LOG_##severity, message); | |
| 39 #define GET_SYNCFS_LOG(_1,_2,_3,NAME,...) NAME | |
| 40 #define SYNCFS_LOG(...) \ | |
| 41 GET_SYNCFS_LOG(__VA_ARGS__, SYNCFS_LOG_WITH_ARGS, SYNCFS_LOG_WITH_NO_ARGS) \ | |
| 42 (__VA_ARGS__) | |
|
tzik
2013/05/24 04:08:32
Could you avoid using macros in other than simples
calvinlo
2013/05/24 05:12:43
Ok, I did a little bit more research on MARCROs an
| |
| 21 | 43 |
| 22 // Returns the log history. | 44 // Returns the log history. |
| 23 // This function can be called from any thread. | 45 // This function can be called from any thread. |
| 24 std::vector<google_apis::EventLogger::Event> GetLogHistory(); | 46 std::vector<google_apis::EventLogger::Event> GetLogHistory(); |
| 25 | 47 |
| 26 } // namespace util | 48 } // namespace util |
| 27 } // namespace sync_file_system | 49 } // namespace sync_file_system |
| 28 | 50 |
| 29 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_LOGGER_H_ | 51 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_LOGGER_H_ |
| OLD | NEW |