ifm3d
log_entry.h
1 // -*- c++ -*-
2 /*
3  * Copyright 2023-present ifm electronic, gmbh
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef IFM3D_COMMON_LOGGING_LOG_ENTRY_H
8 #define IFM3D_COMMON_LOGGING_LOG_ENTRY_H
9 
10 #include <cstdarg>
11 #include <thread>
12 #include <string>
13 
14 #include <ifm3d/common/logging/log_level.h>
15 #include <ifm3d/common/logging/time.h>
16 
17 namespace ifm3d
18 {
19  class LogEntry
20  {
21  public:
22  LogEntry(std::string message,
23  LogLevel log_level,
24  const char* file,
25  const char* function,
26  size_t line)
27  : message_(message),
28  log_level_(log_level),
29  file_(file),
30  func_(function),
31  line_(line),
32  time_(logging_clock::now())
33  {}
34 
35  const logging_timepoint&
36  GetTime() const
37  {
38  return time_;
39  }
40 
41  LogLevel
42  GetLogLevel() const
43  {
44  return log_level_;
45  }
46 
47  size_t
48  GetLine() const
49  {
50  return line_;
51  }
52 
53  const char*
54  GetMessage() const
55  {
56  return message_.c_str();
57  }
58 
59  const char*
60  GetFunc() const
61  {
62  return func_;
63  }
64 
65  const char*
66  GetFile() const
67  {
68  return file_;
69  }
70 
71  private:
72  logging_timepoint time_;
73  const LogLevel log_level_;
74  std::string message_;
75  const size_t line_;
76  const char* const func_;
77  const char* const file_;
78  };
79 }
80 
81 #endif // IFM3D_COMMON_LOGGING_LOG_ENTRY_H
ifm3d::LogEntry
Definition: log_entry.h:19