blob: df97d6ebc6fb6b095d7c88b5d671ddfb253db08c [file] [log] [blame]
John Park33858a32018-09-28 23:05:48 -07001#ifndef AOS_LOGGING_PRINTF_FORMATS_H_
2#define AOS_LOGGING_PRINTF_FORMATS_H_
Brian Silvermana7234c62014-03-24 20:23:25 -07003
John Park33858a32018-09-28 23:05:48 -07004#include "aos/macros.h"
Brian Silvermana7234c62014-03-24 20:23:25 -07005
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 Silvermancb5da1f2015-12-05 22:19:58 -050010// implementations.cc.
Brian Silvermana7234c62014-03-24 20:23:25 -070011
12#define AOS_TIME_FORMAT \
Austin Schuhc69e6792021-02-05 11:20:05 -080013 "%010" PRId32 ".%0" AOS_STRINGIFY(AOS_TIME_NSECONDS_DIGITS) PRId32 "s"
Austin Schuh648b3612017-11-20 01:02:24 -080014#define AOS_TIME_ARGS(sec, nsec) sec, (nsec / AOS_TIME_NSECONDS_DENOMINATOR)
Brian Silvermana7234c62014-03-24 20:23:25 -070015
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 Silverman44f09e72014-12-28 16:27:50 -080025#define AOS_TIME_NSECONDS_DIGITS 6
Brian Silverman54a368e2015-02-14 20:05:33 -050026#define AOS_TIME_NSECONDS_DENOMINATOR 1000
Brian Silvermana7234c62014-03-24 20:23:25 -070027
John Park33858a32018-09-28 23:05:48 -070028#endif // AOS_LOGGING_PRINTF_FORMATS_H_