Added some comments
This commit is contained in:
@@ -5,9 +5,17 @@
|
||||
|
||||
namespace ugly {
|
||||
|
||||
/**
|
||||
* \brief Interface for a generic log-like object.
|
||||
*/
|
||||
class ILogFacility {
|
||||
public:
|
||||
~ILogFacility() = default;
|
||||
/**
|
||||
* \brief Put a message into the log, \c std::vformat -style.
|
||||
* \param fmt Format string.
|
||||
* \param args Format arguments.
|
||||
*/
|
||||
virtual void vlog(std::string_view fmt, std::format_args args) = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
|
||||
namespace ugly {
|
||||
|
||||
/**
|
||||
* \brief Provides \c std::format -style variadic template functions for \ref ILogFacility.
|
||||
*/
|
||||
class LogAlias {
|
||||
public:
|
||||
ILogFacility *mpLog;
|
||||
@@ -19,6 +22,11 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Globally-shared log.
|
||||
*
|
||||
* Should be assigned to by the user, defaults to a null log.
|
||||
*/
|
||||
extern LogAlias log;
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
|
||||
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;
|
||||
@@ -17,6 +20,10 @@ private:
|
||||
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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user