32 lines
722 B
C++
32 lines
722 B
C++
#pragma once
|
|
|
|
#include "ILogFacility.hpp"
|
|
|
|
#include <chrono>
|
|
#include <format>
|
|
#include <ostream>
|
|
#include <string_view>
|
|
#include <string>
|
|
|
|
namespace ugly {
|
|
|
|
/**
|
|
* \brief Log that automatically annotates messages with time and name.
|
|
*/
|
|
class TimestampLog: virtual public ILogFacility {
|
|
private:
|
|
std::chrono::high_resolution_clock::time_point mStartTime;
|
|
std::ostream &mrOutputStream;
|
|
std::string mDescription;
|
|
|
|
public:
|
|
/**
|
|
* \param description Name of the log to appear in the messages.
|
|
* \param os Output stream.
|
|
*/
|
|
TimestampLog(std::string_view description, std::ostream &os);
|
|
void vlog(std::string_view fmt, std::format_args args) override;
|
|
};
|
|
|
|
}
|