Fix message newline issue

Signed-off-by: Ricky Zhang <rickyzhang@gmail.com>
This commit is contained in:
Ricky Zhang 2016-12-22 11:23:25 -05:00
parent 6bf8afddfa
commit fc615b4ac0
No known key found for this signature in database
GPG Key ID: 681AFAEF6CDEDB4C
3 changed files with 13 additions and 13 deletions

View File

@ -40,11 +40,11 @@ namespace g3 {
FileSink::~FileSink() {
std::string exit_msg {"\ng3log g3FileSink shutdown at: "};
exit_msg.append(localtime_formatted(systemtime_now(), internal::time_formatted));
std::string exit_msg {"g3log g3FileSink shutdown at: "};
exit_msg.append(localtime_formatted(systemtime_now(), internal::time_formatted)).append({"\n"});
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;
}

View File

@ -79,8 +79,8 @@ namespace g3 {
std::string header() {
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
ss_entry << "\t\tg3log 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 << "g3log created log at: " << g3::localtime_formatted(g3::systemtime_now(), "%a %b %d %H:%M:%S %Y") << "\n";
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";
return ss_entry.str();
}

View File

@ -27,8 +27,8 @@ namespace g3 {
// helper for setting the normal log details in an entry
std::string LogDetailsToString(const LogMessage& msg) {
std::string out;
out.append("\n" + msg.timestamp() + "\t"
+ msg.level() + " [" + msg.file() + "->" + msg.function() + ":" + msg.line() + "]\t");
out.append(msg.timestamp() + "\t"
+ msg.level() + " [" + msg.file() + "->" + msg.function() + ":" + msg.line() + "]: ");
return out;
}
@ -36,16 +36,16 @@ namespace g3 {
// helper for normal
std::string normalToString(const LogMessage& msg) {
auto out = LogDetailsToString(msg);
out.append('"' + msg.message() + '"');
out.append(msg.message() + '\n');
return out;
}
// helper for fatal signal
std::string fatalSignalToString(const LogMessage& msg) {
std::string out; // clear any previous text and formatting
out.append("\n" + msg.timestamp()
out.append(msg.timestamp()
+ "\n\n***** FATAL SIGNAL RECEIVED ******* \n"
+ '"' + msg.message() + '"');
+ msg.message() + '\n');
return out;
}
@ -53,9 +53,9 @@ namespace g3 {
// helper for fatal exception (windows only)
std::string fatalExceptionToString(const LogMessage& msg) {
std::string out; // clear any previous text and formatting
out.append("\n" + msg.timestamp()
out.append(msg.timestamp()
+ "\n\n***** FATAL EXCEPTION RECEIVED ******* \n"
+ '"' + msg.message() + '"');
+ msg.message() + '\n');
return out;
}
@ -104,7 +104,7 @@ namespace g3 {
// What? Did we hit a custom made level?
auto out = LogDetailsToString(*this);
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;
}