mirror of
https://github.com/KjellKod/g3log.git
synced 2024-12-12 10:23:50 +01:00
VTune performance .... from 4us on average (dual threads performance test) to 3us avarage
This commit is contained in:
parent
fafa4cf96a
commit
9be8f49f66
@ -43,7 +43,7 @@ FileSink::~FileSink() {
|
||||
}
|
||||
void FileSink::fileWrite(LogMessageMover message) {
|
||||
std::ofstream& out(filestream());
|
||||
out << message.get().toString() << std::flush;
|
||||
out << message.get().toString();
|
||||
}
|
||||
|
||||
std::string FileSink::changeLogFile(const std::string& directory) {
|
||||
|
@ -37,38 +37,37 @@ namespace {
|
||||
namespace g2 {
|
||||
|
||||
std::string LogMessage::toString() const {
|
||||
std::ostringstream oss;
|
||||
oss << "\n" << timestamp() << "." << microseconds() << "\t";
|
||||
oss << level() << " [" << file();
|
||||
oss << " L: " << line() << "]\t";
|
||||
std::string out;
|
||||
out.append("\n" + timestamp() + "." + microseconds() + "\t"
|
||||
+ level() + " [" + file() + " L: " + line() + "]\t");
|
||||
|
||||
// Non-fatal Log Message
|
||||
if (false == wasFatal()) {
|
||||
oss << '"' << message() << '"';
|
||||
return oss.str();
|
||||
out.append('"' + message() + '"');
|
||||
return out;
|
||||
}
|
||||
|
||||
if (internal::FATAL_SIGNAL.value == _level.value) {
|
||||
oss.str(""); // clear any previous text and formatting
|
||||
oss << "\n" << timestamp() << "." << microseconds();
|
||||
oss << "\n\n***** FATAL SIGNAL RECEIVED ******* " << std::endl;
|
||||
oss << '"' << message() << '"';
|
||||
return oss.str();
|
||||
out.clear(); // clear any previous text and formatting
|
||||
out.append("\n" + timestamp() + "." + microseconds()
|
||||
+ "\n\n***** FATAL SIGNAL RECEIVED ******* \n"
|
||||
+ '"' + message() + '"');
|
||||
return out;
|
||||
}
|
||||
|
||||
// Not crash scenario but LOG or CONTRACT
|
||||
auto level_value = _level.value;
|
||||
if (FATAL.value == level_value) {
|
||||
oss << "\n\t*******\tEXIT trigger caused by LOG(FATAL) entry: \n\t";
|
||||
oss << '"' << message() << '"';
|
||||
out.append("\n\t*******\tEXIT trigger caused by LOG(FATAL) entry: \n\t"
|
||||
+ '"' + message() + '"');
|
||||
} else if (internal::CONTRACT.value == level_value) {
|
||||
oss << "\n\t *******\tEXIT trigger caused by broken Contract: CHECK(" << _expression << ")\n\t";
|
||||
oss << '"' << message() << '"';
|
||||
out.append("\n\t *******\tEXIT trigger caused by broken Contract: CHECK(" + _expression + ")\n\t"
|
||||
+ '"' + message() + '"');
|
||||
} else {
|
||||
oss << "\n\t*******\tUNKNOWN Log Message Type\n" << '"' << message() << '"';
|
||||
out.append("\n\t*******\tUNKNOWN Log Message Type\n" + '"' + message() + '"');
|
||||
}
|
||||
|
||||
return oss.str();
|
||||
return out;
|
||||
}
|
||||
|
||||
std::string LogMessage::timestamp(const std::string & time_look) const {
|
||||
|
Loading…
Reference in New Issue
Block a user