WANG 6 жил өмнө
parent
commit
904b9508fe

+ 6 - 0
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/LogController.java

@@ -2,6 +2,7 @@ package cn.com.qmth.examcloud.core.basic.api.controller;
 
 import java.util.Map;
 
+import org.apache.commons.lang3.StringUtils;
 import org.slf4j.MDC;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -51,6 +52,11 @@ public class LogController extends ControllerSupport {
 	 * @param info
 	 */
 	private void log(String logger, String level, String code, String info) {
+		if (!code.matches("\\w{1,2}\\-\\d{6}")) {
+			throw new StatusException("B-500002",
+					"code must match regular expression:  \\w{1,2}\\-\\d{6}");
+		}
+		info = StringUtils.replaceAll(info, "[\n\r]", "  ");
 		ExamCloudLog log = getLogger(logger);
 		MDC.put("CODE", code);
 		if ("debug".equalsIgnoreCase(level)) {