protected string BuildLog(M4MLogLevel logLevel, string message, string exceptionMessage, string stackTrace, string callerMemberName, string callerFilePath, int callerLineNumber) { var header = BuildLogInternal(logLevel, message, callerMemberName, callerFilePath, callerLineNumber); header.Append("\n" + exceptionMessage).Append("\n" + stackTrace); return header.ToString(); }
private StringBuilder BuildLogInternal(M4MLogLevel logLevel, string message, string callerMemberName, string callerFilePath, int callerLineNumber) { var header = new StringBuilder("\n"); switch (logLevel) { case M4MLogLevel.Debug: header.Append("[DEBUG] "); break; case M4MLogLevel.Info: header.Append("[INFO] "); break; case M4MLogLevel.Warn: header.Append("[WARN] "); break; case M4MLogLevel.Error: header.Append("[ERROR] "); break; } header.Append(DateTime.Now.ToString("HH:mm:ss")); if (callerFilePath.Equals("") == false && callerMemberName.Equals("") == false) { header.Append("\n"); header.Append("File : '").Append(callerFilePath).Append("'\n"); header.Append("Method : '").Append(callerMemberName).Append("'"); if (callerLineNumber != -1) { header.Append(" at line '").Append(callerLineNumber).Append("'"); } header.Append("\n" + message + "\n"); } return header; }
protected string BuildLog(M4MLogLevel logLevel, string message, string callerMemberName, string callerFilePath, int callerLineNumber) { return BuildLogInternal(logLevel, message, callerMemberName, callerFilePath, callerLineNumber).ToString(); }