33 lines
711 B
C++
33 lines
711 B
C++
|
|
|
|
|
|
#include <chrono>
|
|
#include <format>
|
|
#include <iostream>
|
|
#include <mutex>
|
|
#include <string>
|
|
#include <cstdio>
|
|
#include <cstdarg>
|
|
|
|
#include <uxlogger.hpp>
|
|
|
|
UxLogger uxlogger;
|
|
|
|
static std::mutex mtx;
|
|
|
|
UxLogger::UxLogger(const std::string ilabel) {
|
|
label = ilabel;
|
|
}
|
|
|
|
UxLogger::UxLogger(void) {
|
|
label = "global";
|
|
}
|
|
void UxLogger::Log(const std::string& message) {
|
|
auto now = std::chrono::system_clock::now();
|
|
std::chrono::zoned_time localnow{std::chrono::current_zone(), now};
|
|
std::string timenow = std::format("{:%Y-%m-%dT%H:%M:%OS%Z}", localnow);
|
|
std::lock_guard<std::mutex> lock(mtx);
|
|
std::cout << std::format("{} {} {}\n", timenow, label, message);
|
|
}
|
|
|