日志打印
This commit is contained in:
parent
69331e8951
commit
9cfc4f2a8a
@ -6,9 +6,30 @@
|
|||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
#include "logger.hpp"
|
#include "logger.hpp"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
std::optional<int64_t> getEarliestRecordMsInternal(
|
||||||
|
const std::unordered_map<std::string, std::vector<RecordFileInfo>>& index_)
|
||||||
|
{
|
||||||
|
int64_t earliest = -1;
|
||||||
|
|
||||||
|
for (auto& kv : index_)
|
||||||
|
{
|
||||||
|
for (auto& f : kv.second)
|
||||||
|
{
|
||||||
|
if (earliest < 0 || f.start_ms < earliest) earliest = f.start_ms;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (earliest < 0) return std::nullopt;
|
||||||
|
return earliest;
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
std::shared_ptr<RecordManager> g_record_manager = nullptr;
|
std::shared_ptr<RecordManager> g_record_manager = nullptr;
|
||||||
|
|
||||||
extern std::atomic<bool> g_running;
|
extern std::atomic<bool> g_running;
|
||||||
@ -125,24 +146,6 @@ bool RecordManager::loadSrsConfig()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<int64_t> RecordManager::getEarliestRecordMs()
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(index_mutex_);
|
|
||||||
|
|
||||||
int64_t earliest = -1;
|
|
||||||
|
|
||||||
for (auto& kv : index_)
|
|
||||||
{
|
|
||||||
for (auto& f : kv.second)
|
|
||||||
{
|
|
||||||
if (earliest < 0 || f.start_ms < earliest) earliest = f.start_ms;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (earliest < 0) return std::nullopt;
|
|
||||||
return earliest;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RecordManager::removeExpiredDays()
|
void RecordManager::removeExpiredDays()
|
||||||
{
|
{
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
@ -310,7 +313,11 @@ void RecordManager::startAutoScan(int interval_sec)
|
|||||||
this->scanAll();
|
this->scanAll();
|
||||||
|
|
||||||
// ======= 新增:打印最早录像时间 + 磁盘使用率 =======
|
// ======= 新增:打印最早录像时间 + 磁盘使用率 =======
|
||||||
auto earliestOpt = this->getEarliestRecordMs();
|
std::optional<int64_t> earliestOpt;
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(index_mutex_);
|
||||||
|
earliestOpt = getEarliestRecordMsInternal(index_);
|
||||||
|
}
|
||||||
if (earliestOpt.has_value())
|
if (earliestOpt.has_value())
|
||||||
{
|
{
|
||||||
std::string tReadable = RecordManager::toReadable(earliestOpt.value());
|
std::string tReadable = RecordManager::toReadable(earliestOpt.value());
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user