mirror of
https://github.com/KjellKod/g3log.git
synced 2025-01-31 14:39:54 +01:00
Fix message newline issue
Signed-off-by: Ricky Zhang <rickyzhang@gmail.com>
This commit is contained in:
parent
6bf8afddfa
commit
fc615b4ac0
@ -40,11 +40,11 @@ namespace g3 {
|
|||||||
|
|
||||||
|
|
||||||
FileSink::~FileSink() {
|
FileSink::~FileSink() {
|
||||||
std::string exit_msg {"\ng3log g3FileSink shutdown at: "};
|
std::string exit_msg {"g3log g3FileSink shutdown at: "};
|
||||||
exit_msg.append(localtime_formatted(systemtime_now(), internal::time_formatted));
|
exit_msg.append(localtime_formatted(systemtime_now(), internal::time_formatted)).append({"\n"});
|
||||||
filestream() << exit_msg << std::flush;
|
filestream() << exit_msg << std::flush;
|
||||||
|
|
||||||
exit_msg.append({"\nLog file at: ["}).append(_log_file_with_path).append({"]\n\n"});
|
exit_msg.append({"Log file at: ["}).append(_log_file_with_path).append({"]\n"});
|
||||||
std::cerr << exit_msg << std::flush;
|
std::cerr << exit_msg << std::flush;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,8 +79,8 @@ namespace g3 {
|
|||||||
std::string header() {
|
std::string header() {
|
||||||
std::ostringstream ss_entry;
|
std::ostringstream ss_entry;
|
||||||
// Day Month Date Time Year: is written as "%a %b %d %H:%M:%S %Y" and formatted output as : Wed Sep 19 08:28:16 2012
|
// Day Month Date Time Year: is written as "%a %b %d %H:%M:%S %Y" and formatted output as : Wed Sep 19 08:28:16 2012
|
||||||
ss_entry << "\t\tg3log created log at: " << g3::localtime_formatted(g3::systemtime_now(), "%a %b %d %H:%M:%S %Y") << "\n";
|
ss_entry << "g3log created log at: " << g3::localtime_formatted(g3::systemtime_now(), "%a %b %d %H:%M:%S %Y") << "\n";
|
||||||
ss_entry << "\t\tLOG format: [YYYY/MM/DD hh:mm:ss uuu* LEVEL FILE->FUNCTION:LINE] message";
|
ss_entry << "LOG format: [YYYY/MM/DD hh:mm:ss uuu* LEVEL FILE->FUNCTION:LINE] message";
|
||||||
ss_entry << "\t\t(uuu*: microseconds fractions of the seconds value)\n\n";
|
ss_entry << "\t\t(uuu*: microseconds fractions of the seconds value)\n\n";
|
||||||
return ss_entry.str();
|
return ss_entry.str();
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,8 @@ namespace g3 {
|
|||||||
// helper for setting the normal log details in an entry
|
// helper for setting the normal log details in an entry
|
||||||
std::string LogDetailsToString(const LogMessage& msg) {
|
std::string LogDetailsToString(const LogMessage& msg) {
|
||||||
std::string out;
|
std::string out;
|
||||||
out.append("\n" + msg.timestamp() + "\t"
|
out.append(msg.timestamp() + "\t"
|
||||||
+ msg.level() + " [" + msg.file() + "->" + msg.function() + ":" + msg.line() + "]\t");
|
+ msg.level() + " [" + msg.file() + "->" + msg.function() + ":" + msg.line() + "]: ");
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,16 +36,16 @@ namespace g3 {
|
|||||||
// helper for normal
|
// helper for normal
|
||||||
std::string normalToString(const LogMessage& msg) {
|
std::string normalToString(const LogMessage& msg) {
|
||||||
auto out = LogDetailsToString(msg);
|
auto out = LogDetailsToString(msg);
|
||||||
out.append('"' + msg.message() + '"');
|
out.append(msg.message() + '\n');
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper for fatal signal
|
// helper for fatal signal
|
||||||
std::string fatalSignalToString(const LogMessage& msg) {
|
std::string fatalSignalToString(const LogMessage& msg) {
|
||||||
std::string out; // clear any previous text and formatting
|
std::string out; // clear any previous text and formatting
|
||||||
out.append("\n" + msg.timestamp()
|
out.append(msg.timestamp()
|
||||||
+ "\n\n***** FATAL SIGNAL RECEIVED ******* \n"
|
+ "\n\n***** FATAL SIGNAL RECEIVED ******* \n"
|
||||||
+ '"' + msg.message() + '"');
|
+ msg.message() + '\n');
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,9 +53,9 @@ namespace g3 {
|
|||||||
// helper for fatal exception (windows only)
|
// helper for fatal exception (windows only)
|
||||||
std::string fatalExceptionToString(const LogMessage& msg) {
|
std::string fatalExceptionToString(const LogMessage& msg) {
|
||||||
std::string out; // clear any previous text and formatting
|
std::string out; // clear any previous text and formatting
|
||||||
out.append("\n" + msg.timestamp()
|
out.append(msg.timestamp()
|
||||||
+ "\n\n***** FATAL EXCEPTION RECEIVED ******* \n"
|
+ "\n\n***** FATAL EXCEPTION RECEIVED ******* \n"
|
||||||
+ '"' + msg.message() + '"');
|
+ msg.message() + '\n');
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ namespace g3 {
|
|||||||
// What? Did we hit a custom made level?
|
// What? Did we hit a custom made level?
|
||||||
auto out = LogDetailsToString(*this);
|
auto out = LogDetailsToString(*this);
|
||||||
static const std::string errorUnknown = {"UNKNOWN or Custom made Log Message Type"};
|
static const std::string errorUnknown = {"UNKNOWN or Custom made Log Message Type"};
|
||||||
out.append("\n\t*******" + errorUnknown + "\t\n" + '"' + message() + '"');
|
out.append("\t*******" + errorUnknown + "\n\t" + message() + '\n');
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user