Brian Silverman | cb5da1f | 2015-12-05 22:19:58 -0500 | [diff] [blame] | 1 | #ifndef AOS_COMMON_LOGGING_PRINTF_FORMATS_H_ |
| 2 | #define AOS_COMMON_LOGGING_PRINTF_FORMATS_H_ |
Brian Silverman | a7234c6 | 2014-03-24 20:23:25 -0700 | [diff] [blame] | 3 | |
| 4 | #include "aos/common/macros.h" |
| 5 | |
| 6 | // This file has printf(3) formats and corresponding arguments for printing out |
| 7 | // times and log messages. |
| 8 | // They are all split out as macros because there are 2 things that want to |
| 9 | // print using the same format: log_displayer and PrintMessage in |
Brian Silverman | cb5da1f | 2015-12-05 22:19:58 -0500 | [diff] [blame] | 10 | // implementations.cc. |
Brian Silverman | a7234c6 | 2014-03-24 20:23:25 -0700 | [diff] [blame] | 11 | |
| 12 | #define AOS_TIME_FORMAT \ |
Brian Silverman | d81d7fd | 2015-02-09 01:25:28 -0500 | [diff] [blame] | 13 | "%010" PRId32 ".%0" STRINGIFY(AOS_TIME_NSECONDS_DIGITS) PRId32 "s" |
Austin Schuh | 648b361 | 2017-11-20 01:02:24 -0800 | [diff] [blame^] | 14 | #define AOS_TIME_ARGS(sec, nsec) sec, (nsec / AOS_TIME_NSECONDS_DENOMINATOR) |
Brian Silverman | a7234c6 | 2014-03-24 20:23:25 -0700 | [diff] [blame] | 15 | |
| 16 | #define AOS_LOGGING_BASE_FORMAT \ |
| 17 | "%.*s(%" PRId32 ")(%05" PRIu16 "): %-7s at " AOS_TIME_FORMAT ": " |
| 18 | #define AOS_LOGGING_BASE_ARGS(name_length, name, source, sequence, level, sec, \ |
| 19 | nsec) \ |
| 20 | static_cast<int>(name_length), name, source, sequence, \ |
| 21 | ::aos::logging::log_str(level), AOS_TIME_ARGS(sec, nsec) |
| 22 | |
| 23 | // These 2 define how many digits we use to print out the nseconds fields of |
| 24 | // times. They have to stay matching. |
Brian Silverman | 44f09e7 | 2014-12-28 16:27:50 -0800 | [diff] [blame] | 25 | #define AOS_TIME_NSECONDS_DIGITS 6 |
Brian Silverman | 54a368e | 2015-02-14 20:05:33 -0500 | [diff] [blame] | 26 | #define AOS_TIME_NSECONDS_DENOMINATOR 1000 |
Brian Silverman | a7234c6 | 2014-03-24 20:23:25 -0700 | [diff] [blame] | 27 | |
Brian Silverman | cb5da1f | 2015-12-05 22:19:58 -0500 | [diff] [blame] | 28 | #endif // AOS_COMMON_LOGGING_PRINTF_FORMATS_H_ |