log
This commit is contained in:
47
src/core/CoreService.cpp
Normal file
47
src/core/CoreService.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
#include "CoreService.h"
|
||||
#include "../utils/logs/logging.h"
|
||||
|
||||
CoreService* CoreService::instance()
|
||||
{
|
||||
static CoreService inst;
|
||||
return &inst;
|
||||
}
|
||||
|
||||
CoreService::CoreService(QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_initialized(false)
|
||||
{
|
||||
}
|
||||
|
||||
CoreService::~CoreService()
|
||||
{
|
||||
shutdown();
|
||||
}
|
||||
|
||||
bool CoreService::initialize()
|
||||
{
|
||||
if (m_initialized) {
|
||||
LOG_WARNING() << "CoreService already initialized";
|
||||
return true;
|
||||
}
|
||||
|
||||
LOG_INFO() << "CoreService initializing";
|
||||
m_initialized = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CoreService::shutdown()
|
||||
{
|
||||
if (!m_initialized) {
|
||||
LOG_DEBUG() << "CoreService shutdown called while not initialized";
|
||||
return;
|
||||
}
|
||||
|
||||
LOG_INFO() << "CoreService shutting down";
|
||||
m_initialized = false;
|
||||
}
|
||||
|
||||
bool CoreService::isInitialized() const
|
||||
{
|
||||
return m_initialized;
|
||||
}
|
||||
23
src/core/CoreService.h
Normal file
23
src/core/CoreService.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class CoreService : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static CoreService* instance();
|
||||
|
||||
bool initialize();
|
||||
void shutdown();
|
||||
bool isInitialized() const;
|
||||
|
||||
private:
|
||||
explicit CoreService(QObject* parent = nullptr);
|
||||
~CoreService();
|
||||
|
||||
CoreService(const CoreService&) = delete;
|
||||
CoreService& operator=(const CoreService&) = delete;
|
||||
|
||||
bool m_initialized = false;
|
||||
};
|
||||
7
src/core/memory/LockFreeQueue.h
Normal file
7
src/core/memory/LockFreeQueue.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
// Placeholder for a lock-free ring queue.
|
||||
class LockFreeQueue {
|
||||
public:
|
||||
LockFreeQueue() = default;
|
||||
};
|
||||
7
src/core/memory/MemoryPool.h
Normal file
7
src/core/memory/MemoryPool.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
// Placeholder for a preallocated memory pool.
|
||||
class MemoryPool {
|
||||
public:
|
||||
MemoryPool() = default;
|
||||
};
|
||||
5
src/core/metadata/DataTrace.h
Normal file
5
src/core/metadata/DataTrace.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
// Placeholder for data trace model.
|
||||
struct DataTrace {
|
||||
};
|
||||
5
src/core/metadata/Metadata.h
Normal file
5
src/core/metadata/Metadata.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
// Placeholder for metadata model.
|
||||
struct Metadata {
|
||||
};
|
||||
7
src/core/plugin_system/IProtocolPlugin.h
Normal file
7
src/core/plugin_system/IProtocolPlugin.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
// Placeholder protocol plugin interface.
|
||||
class IProtocolPlugin {
|
||||
public:
|
||||
virtual ~IProtocolPlugin() = default;
|
||||
};
|
||||
7
src/core/plugin_system/PluginManager.h
Normal file
7
src/core/plugin_system/PluginManager.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
// Placeholder for plugin manager.
|
||||
class PluginManager {
|
||||
public:
|
||||
PluginManager() = default;
|
||||
};
|
||||
7
src/message_bus/pipeline/PipelineContext.h
Normal file
7
src/message_bus/pipeline/PipelineContext.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
// Placeholder for pipeline context.
|
||||
class PipelineContext {
|
||||
public:
|
||||
PipelineContext() = default;
|
||||
};
|
||||
7
src/message_bus/pipeline/PipelineEngine.h
Normal file
7
src/message_bus/pipeline/PipelineEngine.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
// Placeholder for pipeline engine.
|
||||
class PipelineEngine {
|
||||
public:
|
||||
PipelineEngine() = default;
|
||||
};
|
||||
7
src/utils/logs/LogStream.h
Normal file
7
src/utils/logs/LogStream.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
// Log stream buffer placeholder.
|
||||
class LogStream {
|
||||
public:
|
||||
LogStream() = default;
|
||||
};
|
||||
36
src/utils/logs/logging.h
Normal file
36
src/utils/logs/logging.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifndef LOGGING_H
|
||||
#define LOGGING_H
|
||||
|
||||
#include <QDebug>
|
||||
#include <QLoggingCategory>
|
||||
#include <QString>
|
||||
#include <cstring>
|
||||
|
||||
|
||||
/**
|
||||
* @file logging.h
|
||||
* @brief 日志宏定义,提供带文件名和函数名的日志输出,并异步存储到数据库
|
||||
*/
|
||||
|
||||
// 获取文件名(不含路径)
|
||||
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
|
||||
|
||||
// 构建来源字符串的辅助宏
|
||||
#define __LOG_SOURCE__ (QString(__FILENAME__) + "." + QString(__FUNCTION__))
|
||||
|
||||
// 日志宏,格式:[文件名.函数名] 消息
|
||||
|
||||
#define LOG_DEBUG() \
|
||||
qDebug() << "[" << "SYSTEM" << "DEBUG" << __LOG_SOURCE__ << "[" << __FILENAME__ << "." << __FUNCTION__ << "]"
|
||||
|
||||
#define LOG_ERROR() \
|
||||
qCritical() << "[" << "SYSTEM" << "ERROR" << __LOG_SOURCE__ << "[" << __FILENAME__ << "." << __FUNCTION__ << "]"
|
||||
|
||||
#define LOG_INFO() \
|
||||
qInfo() << "[" << "SYSTEM" << "INFO" << __LOG_SOURCE__ << "[" << __FILENAME__ << "." << __FUNCTION__ << "]"
|
||||
|
||||
#define LOG_WARNING() \
|
||||
qWarning() << "[" << "SYSTEM" << "WARNING" << __LOG_SOURCE__ << "[" << __FILENAME__ << "." << __FUNCTION__ << "]"
|
||||
|
||||
#endif // LOGGING_H
|
||||
|
||||
Reference in New Issue
Block a user