Changeset 511 for cpp/common/log.cpp
- Timestamp:
- 05/23/16 13:48:45 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/common/log.cpp
r375 r511 9 9 10 10 const char* LOG_LEVEL[] = { "[DEBUG] ", "", "[WARN] ", "[ERROR] ", "[CRITICAL] " }; 11 12 void logMessage(const char *obj, const char *method, int level, const char *msg)13 {14 int line = 0; //all lines except the first one get the "..." prefix15 const char* nextsep;16 do17 {18 nextsep = strchr(msg, '\n');19 if (nextsep == NULL) //last chunk, until the end20 nextsep = strchr(msg, '\0');21 if ((nextsep > msg) && (nextsep[-1] == '\r'))22 nextsep--;23 if (line == 0)24 {25 if (*nextsep == 0) //there was only one line! no need to modify it in any way.26 _logMessageSingleLine(obj, method, level, msg);27 else //first line from multi-line28 _logMessageSingleLine(obj, method, level, string(msg, nextsep - msg).c_str());29 }30 else //consecutive lines from multi-line31 _logMessageSingleLine(obj, method, level, (LOG_MULTILINE_CONTINUATION + string(msg, nextsep - msg)).c_str()); //could also add line numbers like ...(3)... but let's keep the prefix short and simple32 line++;33 if ((nextsep[0] == '\r') && (nextsep[1] == '\n'))34 msg = nextsep + 2;35 else if (*nextsep)36 msg = nextsep + 1;37 } while (*nextsep);38 }39 40 11 41 12 void logPrintf_va(const char *obj, const char *method, int level, const char *msgf, va_list va)
Note: See TracChangeset
for help on using the changeset viewer.