Files
windpacer 16fc7a2598 Initial commit: HC900 Crawler
Honeywell HC900을 Modbus TCP로 직접 폴링 → gRPC → C# 크롤러 → PostgreSQL.
기존 Experion OPC UA 데이터 경로를 HC900 직접 통신으로 대체.

- industrial-comm/cpp: C++ Modbus 게이트웨이 (gRPC 서버)
- src: C# .NET 8 ASP.NET Core 크롤러 + 웹 UI (3-Layer)
- mcp-server: Python FastMCP (RAG/NL2SQL/P&ID)
- 다중 컨트롤러(N-Controller) 지원

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 20:28:14 +09:00

54 lines
1.1 KiB
C++

#pragma once
#include <fstream>
#include <mutex>
#include <string>
#include <chrono>
#include <iomanip>
#include <sstream>
class Logger {
public:
static Logger& instance() {
static Logger inst;
return inst;
}
void set_file(const std::string& path) {
std::lock_guard<std::mutex> lock(mutex_);
if (ofs_.is_open())
ofs_.close();
ofs_.open(path, std::ios::out | std::ios::app);
}
void log(const char* level, const std::string& msg) {
std::lock_guard<std::mutex> lock(mutex_);
if (!ofs_.is_open())
return;
ofs_ << timestamp()
<< " [" << level << "] "
<< msg << "\n";
ofs_.flush();
}
private:
Logger() = default;
std::string timestamp() {
using namespace std::chrono;
auto now = system_clock::now();
auto t = system_clock::to_time_t(now);
std::tm tm{};
localtime_r(&t, &tm);
std::ostringstream oss;
oss << std::put_time(&tm, "%Y-%m-%d %H:%M:%S");
return oss.str();
}
std::ofstream ofs_;
std::mutex mutex_;
};