日志打印
This commit is contained in:
parent
69331e8951
commit
9cfc4f2a8a
@ -6,9 +6,30 @@
|
||||
#include <ctime>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <optional>
|
||||
|
||||
#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;
|
||||
|
||||
extern std::atomic<bool> g_running;
|
||||
@ -125,24 +146,6 @@ bool RecordManager::loadSrsConfig()
|
||||
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()
|
||||
{
|
||||
namespace fs = std::filesystem;
|
||||
@ -310,7 +313,11 @@ void RecordManager::startAutoScan(int interval_sec)
|
||||
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())
|
||||
{
|
||||
std::string tReadable = RecordManager::toReadable(earliestOpt.value());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user