WPILibC++  unspecified
Log.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #ifndef CSCORE_LOG_H_
9 #define CSCORE_LOG_H_
10 
11 #include <support/Logger.h>
12 #include <support/atomic_static.h>
13 
14 namespace cs {
15 
16 class Logger : public wpi::Logger {
17  public:
18  static Logger& GetInstance() {
19  ATOMIC_STATIC(Logger, instance);
20  return instance;
21  }
22  ~Logger();
23 
24  void SetDefaultLogger();
25 
26  private:
27  Logger();
28 
29  ATOMIC_STATIC_DECL(Logger)
30 };
31 
32 #define LOG(level, x) WPI_LOG(cs::Logger::GetInstance(), level, x)
33 
34 #undef ERROR
35 #define ERROR(x) WPI_ERROR(cs::Logger::GetInstance(), x)
36 #define WARNING(x) WPI_WARNING(cs::Logger::GetInstance(), x)
37 #define INFO(x) WPI_INFO(cs::Logger::GetInstance(), x)
38 
39 #define DEBUG(x) WPI_DEBUG(cs::Logger::GetInstance(), x)
40 #define DEBUG1(x) WPI_DEBUG1(cs::Logger::GetInstance(), x)
41 #define DEBUG2(x) WPI_DEBUG2(cs::Logger::GetInstance(), x)
42 #define DEBUG3(x) WPI_DEBUG3(cs::Logger::GetInstance(), x)
43 #define DEBUG4(x) WPI_DEBUG4(cs::Logger::GetInstance(), x)
44 
45 #define SERROR(x) ERROR(GetName() << ": " << x)
46 #define SWARNING(x) WARNING(GetName() << ": " << x)
47 #define SINFO(x) INFO(GetName() << ": " << x)
48 
49 #define SDEBUG(x) DEBUG(GetName() << ": " << x)
50 #define SDEBUG1(x) DEBUG1(GetName() << ": " << x)
51 #define SDEBUG2(x) DEBUG2(GetName() << ": " << x)
52 #define SDEBUG3(x) DEBUG3(GetName() << ": " << x)
53 #define SDEBUG4(x) DEBUG4(GetName() << ": " << x)
54 
55 } // namespace cs
56 
57 #endif // CSCORE_LOG_H_
Definition: SinkImpl.h:19
Definition: Log.h:16
Definition: Logger.h:30