OLD | NEW |
1 /* Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 /* Copyright (c) 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 LIBRARIES_NACL_IO_LOG_H_ | 5 #ifndef LIBRARIES_NACL_IO_LOG_H_ |
6 #define LIBRARIES_NACL_IO_LOG_H_ | 6 #define LIBRARIES_NACL_IO_LOG_H_ |
7 | 7 |
8 #include "sdk_util/macros.h" | 8 #include "sdk_util/macros.h" |
9 | 9 |
10 #define LOG_PREFIX "nacl_io: " | 10 #define LOG_PREFIX "nacl_io: " |
11 | 11 |
| 12 #if defined(NDEBUG) |
| 13 |
| 14 #define LOG_TRACE(format, ...) |
| 15 #define LOG_ERROR(format, ...) |
| 16 #define LOG_WARN(format, ...) |
| 17 |
| 18 #else |
| 19 |
12 #if NACL_IO_LOGGING | 20 #if NACL_IO_LOGGING |
| 21 |
13 #define LOG_TRACE(format, ...) \ | 22 #define LOG_TRACE(format, ...) \ |
14 nacl_io_log(LOG_PREFIX format "\n", ##__VA_ARGS__) | 23 nacl_io_log(LOG_PREFIX format "\n", ##__VA_ARGS__) |
| 24 |
15 #else | 25 #else |
| 26 |
16 #define LOG_TRACE(format, ...) | 27 #define LOG_TRACE(format, ...) |
| 28 |
17 #endif | 29 #endif |
18 | 30 |
19 #define LOG_ERROR(format, ...) \ | 31 #define LOG_ERROR(format, ...) \ |
20 nacl_io_log(LOG_PREFIX "error: " format "\n", ##__VA_ARGS__) | 32 nacl_io_log(LOG_PREFIX "%s:%d: error: " format "\n", \ |
| 33 __FILE__, \ |
| 34 __LINE__, \ |
| 35 ##__VA_ARGS__) |
21 | 36 |
22 #define LOG_WARN(format, ...) \ | 37 #define LOG_WARN(format, ...) \ |
23 nacl_io_log(LOG_PREFIX "warning: " format "\n", ##__VA_ARGS__) | 38 nacl_io_log(LOG_PREFIX "%s:%d: warning: " format "\n", \ |
| 39 __FILE__, \ |
| 40 __LINE__, \ |
| 41 ##__VA_ARGS__) |
| 42 |
| 43 #endif |
24 | 44 |
25 EXTERN_C_BEGIN | 45 EXTERN_C_BEGIN |
26 | 46 |
27 /* | 47 /* |
28 * Low level logging function for nacl_io log messages. | 48 * Low level logging function for nacl_io log messages. |
29 * | 49 * |
30 * This function sends its output directly to the IRT standard out | 50 * This function sends its output directly to the IRT standard out |
31 * file descriptor, which by default will apear on the standard out | 51 * file descriptor, which by default will apear on the standard out |
32 * or chrome or sel_ldr. | 52 * or chrome or sel_ldr. |
33 */ | 53 */ |
34 void nacl_io_log(const char* format, ...) PRINTF_LIKE(1, 2); | 54 void nacl_io_log(const char* format, ...) PRINTF_LIKE(1, 2); |
35 | 55 |
36 EXTERN_C_END | 56 EXTERN_C_END |
37 | 57 |
38 #endif /* LIBRARIES_NACL_IO_LOG_H_ */ | 58 #endif /* LIBRARIES_NACL_IO_LOG_H_ */ |
OLD | NEW |