swift
utils.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2013 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #ifndef SWIFT_SIM_XSWIFTBUS_UTILS_H
7 #define SWIFT_SIM_XSWIFTBUS_UTILS_H
8 
9 #include <string>
10 #include <vector>
11 
12 namespace XSwiftBus
13 {
15  extern std::string g_xplanePath;
16 
18  extern std::string g_sep;
19 
22 
25  class Logger
26  {
27  public:
29  enum MsgType
30  {
31  DebugMsg,
32  WarningMsg,
33  ErrorMsg,
34  InfoMsg
35  };
36 
37  Logger() = delete;
38 
40  static void print(const std::string &filePath, int line, MsgType type, const std::string &message);
41  };
42 } // namespace XSwiftBus
43 
46 // *INDENT-OFF*
47 #define DEBUG_LOG(msg) (XSwiftBus::Logger::print(__FILE__, __LINE__, XSwiftBus::Logger::DebugMsg, (msg)))
48 #define DEBUG_LOG_C(msg, doLog) \
49  ((doLog) ? XSwiftBus::Logger::print(__FILE__, __LINE__, XSwiftBus::Logger::DebugMsg, (msg)) : static_cast<void>(0))
50 #define INFO_LOG(msg) (XSwiftBus::Logger::print(__FILE__, __LINE__, XSwiftBus::Logger::InfoMsg, (msg)))
51 #define WARNING_LOG(msg) (XSwiftBus::Logger::print(__FILE__, __LINE__, XSwiftBus::Logger::WarningMsg, (msg)))
52 #define ERROR_LOG(msg) (XSwiftBus::Logger::print(__FILE__, __LINE__, XSwiftBus::Logger::ErrorMsg, (msg)))
53 // *INDENT-ON*
55 
56 #endif // SWIFT_SIM_XSWIFTBUS_UTILS_H
Simple logger class. Don't use it directly, but the _LOG macros instead.
Definition: utils.h:26
MsgType
Message type.
Definition: utils.h:30
static void print(const std::string &filePath, int line, MsgType type, const std::string &message)
Print message to X-Plane log.
Plugin loaded by X-Plane which publishes a DBus service.
Definition: command.h:14
std::string g_xplanePath
Absolute xplane path.
std::string g_sep
Platform specific dir separator.
void initXPlanePath()
Init global xplane path.