21 #ifndef CYBER_LOGGER_LOGGER_UTIL_H_ 22 #define CYBER_LOGGER_LOGGER_UTIL_H_ 26 #include <sys/utsname.h> 43 gettimeofday(&tv,
nullptr);
44 return static_cast<int64_t
>(tv.tv_sec) * 1000000 + tv.tv_usec;
49 static inline void GetHostName(std::string* hostname) {
51 if (0 != uname(&buf)) {
55 *hostname = buf.nodename;
63 return (FLAGS_max_log_size > 0 ? FLAGS_max_log_size : 1);
66 inline void FindModuleName(std::string* log_message, std::string* module_name) {
68 if (lpos != std::string::npos) {
70 if (rpos != std::string::npos) {
71 module_name->assign(*log_message, lpos + 1, rpos - lpos - 1);
72 auto cut_length = rpos - lpos + 1;
73 log_message->erase(lpos, cut_length);
76 if (module_name->empty()) {
86 #endif // CYBER_LOGGER_LOGGER_UTIL_H_ PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
int32_t MaxLogSize()
Definition: logger_util.h:62
void FindModuleName(std::string *log_message, std::string *module_name)
Definition: logger_util.h:66
int64_t CycleClock_Now()
Definition: logger_util.h:41
#define RIGHT_BRACKET
Definition: log.h:33
#define LEFT_BRACKET
Definition: log.h:32
int32_t GetMainThreadPid()
int64_t UsecToCycles(int64_t usec)
Definition: logger_util.h:47