mirror of
https://github.com/KjellKod/g3log.git
synced 2025-04-16 23:12:59 +02:00
Thanks to Aleksey Dobrunov: Improvement by making all raw data in the g2logmessage public
Added explaining comments to g2logmessage
This commit is contained in:
parent
cb7c0f8ac5
commit
1ac2e9070e
@ -22,12 +22,23 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace g2 {
|
namespace g2 {
|
||||||
|
|
||||||
|
/** LogMessage contains all the data collected from the LOG(...) call.
|
||||||
|
* If the sink receives a std::string it will be the std::string toString()... function
|
||||||
|
* that will format the data into a string
|
||||||
|
*
|
||||||
|
* For sinks that receive a LogMessage they can either use the toString() function, or use
|
||||||
|
* the helper functions or even the public raw data to format the saved log message any
|
||||||
|
* desired way.
|
||||||
|
*/
|
||||||
struct LogMessage {
|
struct LogMessage {
|
||||||
std::string file() const { return _file; }
|
std::string file() const { return _file; }
|
||||||
std::string line() const { return std::to_string(_line); }
|
std::string line() const { return std::to_string(_line); }
|
||||||
std::string function() const { return _function; }
|
std::string function() const { return _function; }
|
||||||
std::string level() const { return _level.text; }
|
std::string level() const { return _level.text; }
|
||||||
|
|
||||||
|
/// use a different format string to get a different look on the time.
|
||||||
|
// default look is Y/M/D H:M:S
|
||||||
std::string timestamp(const std::string& time_format = {internal::date_formatted + " " + internal::time_formatted}) const;
|
std::string timestamp(const std::string& time_format = {internal::date_formatted + " " + internal::time_formatted}) const;
|
||||||
std::string microseconds() const { return std::to_string(_microseconds); }
|
std::string microseconds() const { return std::to_string(_microseconds); }
|
||||||
|
|
||||||
@ -48,10 +59,10 @@ namespace g2 {
|
|||||||
LogMessage(LogMessage&& other);
|
LogMessage(LogMessage&& other);
|
||||||
virtual ~LogMessage(){};
|
virtual ~LogMessage(){};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Complete access to the raw data in case the helper functions above
|
||||||
|
// are not enough.
|
||||||
protected:
|
//
|
||||||
std::time_t _timestamp;
|
std::time_t _timestamp;
|
||||||
int64_t _microseconds;
|
int64_t _microseconds;
|
||||||
std::string _file;
|
std::string _file;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user