Apollo 10.0
自动驾驶开放平台
apollo::cyber::logger 命名空间参考

class  AsyncLogger
 
class  LogFileObject
 
class  Logger
 

类型定义

typedef int32_t int32
 
typedef uint32_t uint32
 
typedef int64_t int64
 
typedef uint64_t uint64
 

函数

int32_t GetMainThreadPid ()
 
bool PidHasChanged ()
 
int64_t CycleClock_Now ()
 
int64_t UsecToCycles (int64_t usec)
 
int32_t MaxLogSize ()
 
void FindModuleName (std::string *log_message, std::string *module_name)
 

变量

const char *const LogSeverityNames [NUM_SEVERITIES]
 

类型定义说明

◆ int32

在文件 log_file_object.h32 行定义.

◆ int64

在文件 log_file_object.h34 行定义.

◆ uint32

在文件 log_file_object.h33 行定义.

◆ uint64

在文件 log_file_object.h35 行定义.

函数说明

◆ CycleClock_Now()

int64_t apollo::cyber::logger::CycleClock_Now ( )
inline

在文件 logger_util.h41 行定义.

41 {
42 struct timeval tv;
43 gettimeofday(&tv, nullptr);
44 return static_cast<int64_t>(tv.tv_sec) * 1000000 + tv.tv_usec;
45}

◆ FindModuleName()

void apollo::cyber::logger::FindModuleName ( std::string *  log_message,
std::string *  module_name 
)
inline

在文件 logger_util.h66 行定义.

66 {
67 auto lpos = log_message->find(LEFT_BRACKET);
68 if (lpos != std::string::npos) {
69 auto rpos = log_message->find(RIGHT_BRACKET, lpos);
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);
74 }
75 }
76 if (module_name->empty()) {
77 CHECK_NOTNULL(common::GlobalData::Instance());
78 *module_name = common::GlobalData::Instance()->ProcessGroup();
79 }
80}
#define LEFT_BRACKET
@log
Definition log.h:32
#define RIGHT_BRACKET
Definition log.h:33

◆ GetMainThreadPid()

int32_t apollo::cyber::logger::GetMainThreadPid ( )

在文件 logger_util.cc38 行定义.

38{ return g_main_thread_pid; }

◆ MaxLogSize()

int32_t apollo::cyber::logger::MaxLogSize ( )
inline

在文件 logger_util.h62 行定义.

62 {
63 return (FLAGS_max_log_size > 0 ? FLAGS_max_log_size : 1);
64}

◆ PidHasChanged()

bool apollo::cyber::logger::PidHasChanged ( )

在文件 logger_util.cc40 行定义.

40 {
41 int32_t pid = getpid();
42 if (g_main_thread_pid == pid) {
43 return false;
44 }
45 g_main_thread_pid = pid;
46 return true;
47}

◆ UsecToCycles()

int64_t apollo::cyber::logger::UsecToCycles ( int64_t  usec)
inline

在文件 logger_util.h47 行定义.

47{ return usec; }

变量说明

◆ LogSeverityNames

const char* const apollo::cyber::logger::LogSeverityNames[NUM_SEVERITIES]
初始值:
= {"INFO", "WARNING",
"ERROR", "FATAL"}

在文件 log_file_object.cc69 行定义.

69 {"INFO", "WARNING",
70 "ERROR", "FATAL"};