mirror of
https://github.com/KjellKod/g3log.git
synced 2024-12-12 10:23:50 +01:00
Added threadID in case someone wants that. The std:🧵:id is looong. cutting it down would be nice,. but that is a job for the client
This commit is contained in:
parent
9be8f49f66
commit
98ec05db7b
@ -77,8 +77,12 @@ namespace g2 {
|
|||||||
LogMessage::LogMessage(const std::string &file, const int line,
|
LogMessage::LogMessage(const std::string &file, const int line,
|
||||||
const std::string& function, const LEVELS& level)
|
const std::string& function, const LEVELS& level)
|
||||||
: _timestamp(g2::systemtime_now())
|
: _timestamp(g2::systemtime_now())
|
||||||
|
, _call_thread_id(std::this_thread::get_id())
|
||||||
, _microseconds(microsecondsCounter())
|
, _microseconds(microsecondsCounter())
|
||||||
, _file(splitFileName(file)), _line(line), _function(function), _level(level)
|
, _file(splitFileName(file))
|
||||||
|
, _line(line)
|
||||||
|
, _function(function)
|
||||||
|
, _level(level)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -89,6 +93,7 @@ namespace g2 {
|
|||||||
|
|
||||||
LogMessage::LogMessage(const LogMessage& other)
|
LogMessage::LogMessage(const LogMessage& other)
|
||||||
: _timestamp(other._timestamp)
|
: _timestamp(other._timestamp)
|
||||||
|
, _call_thread_id(other._call_thread_id)
|
||||||
, _microseconds(other._microseconds)
|
, _microseconds(other._microseconds)
|
||||||
, _file(other._file)
|
, _file(other._file)
|
||||||
, _line(other._line)
|
, _line(other._line)
|
||||||
@ -102,6 +107,7 @@ namespace g2 {
|
|||||||
|
|
||||||
LogMessage::LogMessage(LogMessage&& other)
|
LogMessage::LogMessage(LogMessage&& other)
|
||||||
: _timestamp(other._timestamp)
|
: _timestamp(other._timestamp)
|
||||||
|
, _call_thread_id(other._call_thread_id)
|
||||||
, _microseconds(other._microseconds)
|
, _microseconds(other._microseconds)
|
||||||
, _file(std::move(other._file))
|
, _file(std::move(other._file))
|
||||||
, _line(other._line)
|
, _line(other._line)
|
||||||
@ -110,6 +116,13 @@ namespace g2 {
|
|||||||
, _expression(std::move(other._expression))
|
, _expression(std::move(other._expression))
|
||||||
, _message(std::move(other._message)) {
|
, _message(std::move(other._message)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string LogMessage::threadID() const {
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << _call_thread_id;
|
||||||
|
return oss.str();
|
||||||
|
}
|
||||||
|
|
||||||
FatalMessage::FatalMessage(const LogMessage& details, int signal_id)
|
FatalMessage::FatalMessage(const LogMessage& details, int signal_id)
|
||||||
: LogMessage(details), _signal_id(signal_id) { }
|
: LogMessage(details), _signal_id(signal_id) { }
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
#include "g2loglevels.hpp"
|
#include "g2loglevels.hpp"
|
||||||
#include "g2time.hpp"
|
#include "g2time.hpp"
|
||||||
@ -47,6 +48,8 @@ namespace g2 {
|
|||||||
|
|
||||||
std::string expression() const { return _expression; }
|
std::string expression() const { return _expression; }
|
||||||
bool wasFatal() const { return internal::wasFatal(_level); }
|
bool wasFatal() const { return internal::wasFatal(_level); }
|
||||||
|
|
||||||
|
std::string threadID() const;
|
||||||
|
|
||||||
std::string toString() const;
|
std::string toString() const;
|
||||||
void setExpression(const std::string expression) { _expression = expression; }
|
void setExpression(const std::string expression) { _expression = expression; }
|
||||||
@ -64,6 +67,7 @@ namespace g2 {
|
|||||||
// are not enough.
|
// are not enough.
|
||||||
//
|
//
|
||||||
std::time_t _timestamp;
|
std::time_t _timestamp;
|
||||||
|
std::thread::id _call_thread_id;
|
||||||
int64_t _microseconds;
|
int64_t _microseconds;
|
||||||
std::string _file;
|
std::string _file;
|
||||||
int _line;
|
int _line;
|
||||||
|
Loading…
Reference in New Issue
Block a user