code: public static String getStackTraceLog(String msg, Throwable e) {
          StringBuilder b = new StringBuilder();
          b.append(msg).append("\n");
  
          if (e != null) {
              b.append(e.toString()).append("\n");
  
              StackTraceElement[] elements = e.getStackTrace();
              StackTraceElement element;
  
              if (elements != null) {
  
                  for (int i = 0; i < elements.length && i < STACKTRACE_LIMIT; i++) {
                      element = elements[i];
  
                      if (element != null) {
                          b.append("\tat ").append(element.toString()).append("\n");
                      }
                  }
                  int more = elements.length - STACKTRACE_LIMIT;
                  if (more > 0) {
                      b.append("\t... ").append(more).append(" more").append("\n");
                  }
              }
          }
  
          return b.toString();
      }
docs: End method