log0.1
This commit is contained in:
0
src/api/ipc_dbus/Ipc_dbus.cpp
Normal file
0
src/api/ipc_dbus/Ipc_dbus.cpp
Normal file
62
src/api/ipc_dbus/Ipc_dbus.h
Normal file
62
src/api/ipc_dbus/Ipc_dbus.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* @file Ipc_dbus.h
|
||||
* @brief D-Bus 服务接口 - 提供核心服务状态和负载查询
|
||||
*/
|
||||
|
||||
#ifndef IPC_DBUS_H
|
||||
#define IPC_DBUS_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
|
||||
/**
|
||||
* @brief D-Bus 服务适配器 - 暴露核心服务接口
|
||||
*/
|
||||
class IpcDBus : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", "com.softbus.Daemon")
|
||||
|
||||
public:
|
||||
explicit IpcDBus(CoreService* coreService, QObject* parent = nullptr);
|
||||
~IpcDBus();
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* @brief 检查核心服务是否运行
|
||||
* @return true 如果核心服务正在运行
|
||||
*/
|
||||
bool isRunning() const;
|
||||
|
||||
/**
|
||||
* @brief 获取核心服务状态信息
|
||||
* @return JSON 格式的状态信息
|
||||
*/
|
||||
QString getStatus() const;
|
||||
|
||||
|
||||
/**
|
||||
* @brief 获取守护进程的进程ID
|
||||
* @return 进程ID,如果无法获取则返回0
|
||||
*/
|
||||
qint64 getPid() const;
|
||||
|
||||
/**
|
||||
* @brief 关闭守护进程
|
||||
*/
|
||||
void shutdown();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private slots:
|
||||
void updateLoadInfo();
|
||||
|
||||
private:
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // IPC_DBUS_H
|
||||
|
||||
@@ -7,6 +7,13 @@ class CoreService : public QObject {
|
||||
|
||||
public:
|
||||
static CoreService* instance();
|
||||
enum Role {
|
||||
CoreRouter, // 核心路由器,负责设备发现、连接管理和数据转发
|
||||
Collector, // 数据收集器,负责从设备收集数据
|
||||
CollectorSerial, // 串口数据收集器
|
||||
CollectorCan, // CAN总线数据收集器
|
||||
SqlServer, // SQL服务器,负责存储设备数据
|
||||
};
|
||||
|
||||
bool initialize();
|
||||
void shutdown();
|
||||
|
||||
@@ -16,21 +16,21 @@
|
||||
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
|
||||
|
||||
// 构建来源字符串的辅助宏
|
||||
#define __LOG_SOURCE__ (QString(__FILENAME__) + "." + QString(__FUNCTION__))
|
||||
// #define __LOG_SOURCE__ (QString(__FILENAME__) + "." + QString(__FUNCTION__))
|
||||
|
||||
// 日志宏,格式:[文件名.函数名] 消息
|
||||
|
||||
#define LOG_DEBUG() \
|
||||
qDebug() << "[" << "SYSTEM" << "DEBUG" << __LOG_SOURCE__ << "[" << __FILENAME__ << "." << __FUNCTION__ << "]"
|
||||
qDebug() << "[" << __FILENAME__ << "/" << __FUNCTION__ << "]"
|
||||
|
||||
#define LOG_ERROR() \
|
||||
qCritical() << "[" << "SYSTEM" << "ERROR" << __LOG_SOURCE__ << "[" << __FILENAME__ << "." << __FUNCTION__ << "]"
|
||||
qCritical() << "[" << __FILENAME__ << "/" << __FUNCTION__ << "]"
|
||||
|
||||
#define LOG_INFO() \
|
||||
qInfo() << "[" << "SYSTEM" << "INFO" << __LOG_SOURCE__ << "[" << __FILENAME__ << "." << __FUNCTION__ << "]"
|
||||
qInfo() << "[" << __FILENAME__ << "/" << __FUNCTION__ << "]"
|
||||
|
||||
#define LOG_WARNING() \
|
||||
qWarning() << "[" << "SYSTEM" << "WARNING" << __LOG_SOURCE__ << "[" << __FILENAME__ << "." << __FUNCTION__ << "]"
|
||||
qWarning() << "[" << __FILENAME__ << "/" << __FUNCTION__ << "]"
|
||||
|
||||
#endif // LOGGING_H
|
||||
|
||||
|
||||
Reference in New Issue
Block a user