add module log

This commit is contained in:
fit2-zhao 2023-04-17 14:23:33 +08:00
parent cceb8032b7
commit a9d10b32fc
16 changed files with 1660 additions and 87 deletions

View File

@ -0,0 +1 @@
logging.file.path=/opt/metersphere/logs/metersphere/

View File

@ -0,0 +1,471 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="true">
<property resource="application.properties"/>
<property resource="commons.properties"/>
<property file="/opt/metersphere/conf/metersphere.properties"/>
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d %5p %40.40c:%4L - %m%n</pattern>
</encoder>
</appender>
<appender name="debugAppender"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>DEBUG</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<File>${logging.file.path}/debug.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${logging.file.path}/history/debug.%d{yyyyMMdd}-%i.log
</FileNamePattern>
<maxHistory>${logger.max.history:-30}</maxHistory>
<TimeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>50MB</maxFileSize>
</TimeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<charset>UTF-8</charset>
<Pattern>%d [%thread] %-5level %logger{36} %line - %msg%n</Pattern>
</encoder>
</appender>
<appender name="infoAppender"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<File>${logging.file.path}/info.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${logging.file.path}/history/info.%d{yyyyMMdd}-%i.log
</FileNamePattern>
<maxHistory>${logger.max.history:-30}</maxHistory>
<TimeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>50MB</maxFileSize>
</TimeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<charset>UTF-8</charset>
<Pattern>%d [%thread] %-5level %logger{36} %line - %msg%n</Pattern>
</encoder>
</appender>
<appender name="errorAppender"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<File>${logging.file.path}/error.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${logging.file.path}/history/error.%d{yyyyMMdd}-%i.log
</FileNamePattern>
<maxHistory>${logger.max.history:-30}</maxHistory>
<TimeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>50MB</maxFileSize>
</TimeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<charset>UTF-8</charset>
<Pattern>%d [%thread] %-5level %logger{36} %line - %msg%n</Pattern>
</encoder>
</appender>
<appender name="warnAppender"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>WARN</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<File>${logging.file.path}/warn.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${logging.file.path}/history/warn.%d{yyyyMMdd}-%i.log
</FileNamePattern>
<maxHistory>${logger.max.history:-30}</maxHistory>
<TimeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>50MB</maxFileSize>
</TimeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<charset>UTF-8</charset>
<Pattern>%d [%thread] %-5level %logger{36} %line - %msg%n</Pattern>
</encoder>
</appender>
<appender name="consoleAsyncAppender" class="ch.qos.logback.classic.AsyncAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>DEBUG</level>
</filter>
<queueSize>10000</queueSize>
<appender-ref ref="console"/>
</appender>
<appender name="debugAsyncAppender" class="ch.qos.logback.classic.AsyncAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>DEBUG</level>
</filter>
<queueSize>10000</queueSize>
<appender-ref ref="debugAppender"/>
</appender>
<appender name="infoAsyncAppender" class="ch.qos.logback.classic.AsyncAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<queueSize>10000</queueSize>
<appender-ref ref="infoAppender"/>
</appender>
<appender name="errorAsyncAppender" class="ch.qos.logback.classic.AsyncAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
<queueSize>10000</queueSize>
<includeCallerData>true</includeCallerData>
<appender-ref ref="errorAppender"/>
</appender>
<appender name="warnAsyncAppender" class="ch.qos.logback.classic.AsyncAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>WARN</level>
</filter>
<queueSize>10000</queueSize>
<includeCallerData>true</includeCallerData>
<appender-ref ref="warnAppender"/>
</appender>
<!-- 自定义api-test模块日志 -->
<appender name="apiAppender"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<File>${logging.file.path}/api-test.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${logging.file.path}/history/api-test.%d{yyyyMMdd}-%i.log
</FileNamePattern>
<maxHistory>${logger.max.history:-30}</maxHistory>
<TimeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>50MB</maxFileSize>
</TimeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<charset>UTF-8</charset>
<Pattern>%d %t %-5level %logger{36} %line - %msg%n</Pattern>
</encoder>
</appender>
<appender name="apiTestAppender" class="ch.qos.logback.classic.AsyncAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<queueSize>10000</queueSize>
<appender-ref ref="apiAppender"/>
</appender>
<logger name="api-test" additivity="false">
<level value="${logger.level:INFO}"/>
<appender-ref ref="apiTestAppender"/>
</logger>
<!-- 自定义load-test模块日志 -->
<appender name="loadAppender"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<File>${logging.file.path}/load-test.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${logging.file.path}/history/load-test.%d{yyyyMMdd}-%i.log
</FileNamePattern>
<maxHistory>${logger.max.history:-30}</maxHistory>
<TimeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>50MB</maxFileSize>
</TimeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<charset>UTF-8</charset>
<Pattern>%d %t %-5level %logger{36} %line - %msg%n</Pattern>
</encoder>
</appender>
<appender name="loadTestAppender" class="ch.qos.logback.classic.AsyncAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<queueSize>10000</queueSize>
<appender-ref ref="loadAppender"/>
</appender>
<logger name="load-test" additivity="false">
<level value="${logger.level:INFO}"/>
<appender-ref ref="loadTestAppender"/>
</logger>
<!-- 自定义project-management模块日志 -->
<appender name="projectAppender"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<File>${logging.file.path}/project.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${logging.file.path}/history/project.%d{yyyyMMdd}-%i.log
</FileNamePattern>
<maxHistory>${logger.max.history:-30}</maxHistory>
<TimeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>50MB</maxFileSize>
</TimeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<charset>UTF-8</charset>
<Pattern>%d %t %-5level %logger{36} %line - %msg%n</Pattern>
</encoder>
</appender>
<appender name="projectManagementAppender" class="ch.qos.logback.classic.AsyncAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<queueSize>10000</queueSize>
<appender-ref ref="projectAppender"/>
</appender>
<logger name="project-management" additivity="false">
<level value="${logger.level:INFO}"/>
<appender-ref ref="projectManagementAppender"/>
</logger>
<!-- 自定义system-setting模块日志 -->
<appender name="systemAppender"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<File>${logging.file.path}/system-setting.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${logging.file.path}/history/system-setting.%d{yyyyMMdd}-%i.log
</FileNamePattern>
<maxHistory>${logger.max.history:-30}</maxHistory>
<TimeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>50MB</maxFileSize>
</TimeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<charset>UTF-8</charset>
<Pattern>%d %t %-5level %logger{36} %line - %msg%n</Pattern>
</encoder>
</appender>
<appender name="systemSettingAppender" class="ch.qos.logback.classic.AsyncAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<queueSize>10000</queueSize>
<appender-ref ref="systemAppender"/>
</appender>
<logger name="system-setting" additivity="false">
<level value="${logger.level:INFO}"/>
<appender-ref ref="systemSettingAppender"/>
</logger>
<!-- 自定义test-plan模块日志 -->
<appender name="testPlanAppender"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<File>${logging.file.path}/test-plan.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${logging.file.path}/history/test-plan.%d{yyyyMMdd}-%i.log
</FileNamePattern>
<maxHistory>${logger.max.history:-30}</maxHistory>
<TimeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>50MB</maxFileSize>
</TimeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<charset>UTF-8</charset>
<Pattern>%d %t %-5level %logger{36} %line - %msg%n</Pattern>
</encoder>
</appender>
<appender name="testPlanRefAppender" class="ch.qos.logback.classic.AsyncAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<queueSize>10000</queueSize>
<appender-ref ref="testPlanAppender"/>
</appender>
<logger name="test-plan" additivity="false">
<level value="${logger.level:INFO}"/>
<appender-ref ref="testPlanRefAppender"/>
</logger>
<!-- 自定义test-track模块日志 -->
<appender name="testTrackAppender"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<File>${logging.file.path}/test-track.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${logging.file.path}/history/test-track.%d{yyyyMMdd}-%i.log
</FileNamePattern>
<maxHistory>${logger.max.history:-30}</maxHistory>
<TimeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>50MB</maxFileSize>
</TimeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<charset>UTF-8</charset>
<Pattern>%d %t %-5level %logger{36} %line - %msg%n</Pattern>
</encoder>
</appender>
<appender name="testTrackRefAppender" class="ch.qos.logback.classic.AsyncAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<queueSize>10000</queueSize>
<appender-ref ref="testTrackAppender"/>
</appender>
<logger name="test-track" additivity="false">
<level value="${logger.level:INFO}"/>
<appender-ref ref="testTrackRefAppender"/>
</logger>
<!-- 自定义ui-test模块日志 -->
<appender name="uiTestAppender"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<File>${logging.file.path}/ui-test.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${logging.file.path}/history/ui-test.%d{yyyyMMdd}-%i.log
</FileNamePattern>
<maxHistory>${logger.max.history:-30}</maxHistory>
<TimeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>50MB</maxFileSize>
</TimeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<charset>UTF-8</charset>
<Pattern>%d %t %-5level %logger{36} %line - %msg%n</Pattern>
</encoder>
</appender>
<appender name="uiTestRefAppender" class="ch.qos.logback.classic.AsyncAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<queueSize>10000</queueSize>
<appender-ref ref="uiTestAppender"/>
</appender>
<logger name="ui-test" additivity="false">
<level value="${logger.level:INFO}"/>
<appender-ref ref="uiTestRefAppender"/>
</logger>
<!-- 自定义workstation模块日志 -->
<appender name="workstationAppender"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<File>${logging.file.path}/workstation.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${logging.file.path}/history/workstation.%d{yyyyMMdd}-%i.log
</FileNamePattern>
<maxHistory>${logger.max.history:-30}</maxHistory>
<TimeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>50MB</maxFileSize>
</TimeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<charset>UTF-8</charset>
<Pattern>%d %t %-5level %logger{36} %line - %msg%n</Pattern>
</encoder>
</appender>
<appender name="workstationRefAppender" class="ch.qos.logback.classic.AsyncAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<queueSize>10000</queueSize>
<appender-ref ref="workstationAppender"/>
</appender>
<logger name="workstation" additivity="false">
<level value="${logger.level:INFO}"/>
<appender-ref ref="workstationRefAppender"/>
</logger>
<!-- 自定义API执行过程日志 -->
<appender name="apiRunLogAppender"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<File>${logging.file.path}/ms-jmeter-run.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${logging.file.path}/history/ms-jmeter-run-log.%d{yyyyMMdd}-%i.log
</FileNamePattern>
<maxHistory>${logger.max.history:-30}</maxHistory>
<TimeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>50MB</maxFileSize>
</TimeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<charset>UTF-8</charset>
<Pattern>%d %t %-5level %logger{36} %line - %msg%n</Pattern>
</encoder>
</appender>
<appender name="runLogAppender" class="ch.qos.logback.classic.AsyncAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<queueSize>10000</queueSize>
<appender-ref ref="apiRunLogAppender"/>
</appender>
<logger name="ms-jmeter-run-log" additivity="false">
<level value="${logger.level:INFO}"/>
<appender-ref ref="runLogAppender"/>
</logger>
<!-- 自定义JMETER输出日志 -->
<appender name="JMETER_LOG" class="io.metersphere.api.jmeter.JMeterLoggerAppender"/>
<root level="INFO">
<appender-ref ref="infoAsyncAppender"/>
<appender-ref ref="console"/>
</root>
<!--将JMETER日志单独输出的包路径-->
<logger name="org.apache.jmeter" additivity="false" level="INFO">
<appender-ref ref="JMETER_LOG"/>
</logger>
<logger name="io.metersphere" additivity="false">
<level value="${logger.level:INFO}"/>
<appender-ref ref="infoAsyncAppender"/>
<appender-ref ref="warnAsyncAppender"/>
<appender-ref ref="errorAsyncAppender"/>
</logger>
<logger name="io.metersphere.base.mapper" level="${logger.sql.level}">
<appender-ref ref="console"/>
</logger>
<logger name="io.metersphere.ApiApplication" additivity="false" level="${logger.level:INFO}">
<appender-ref ref="infoAsyncAppender"/>
</logger>
</configuration>

View File

@ -2,7 +2,7 @@ package io.metersphere.plugin.api.dto;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import io.metersphere.plugin.util.LogUtil;
import io.metersphere.plugin.util.PluginLogUtils;
import lombok.Data;
import org.apache.jmeter.save.SaveService;
@ -66,8 +66,7 @@ public abstract class TestElementDTO {
SaveService.saveTree(hashTree, bas);
return bas.toString();
} catch (Exception e) {
e.printStackTrace();
LogUtil.warn("HashTree error, can't log jmx scenarioDefinition");
PluginLogUtils.error("HashTree error, can't log jmx scenarioDefinition");
}
return null;
}

View File

@ -3,11 +3,7 @@ package io.metersphere.plugin.util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
public class LogUtil {
public class PluginLogUtils {
public static final String DEBUG = "DEBUG";
public static final String INFO = "INFO";
public static final String WARN = "WARN";
@ -19,27 +15,27 @@ public class LogUtil {
* @return
*/
public static Logger getLogger() {
return LoggerFactory.getLogger(LogUtil.getLogClass());
return LoggerFactory.getLogger(PluginLogUtils.getLogClass());
}
public static void writeLog(Object msg, String level) {
Logger logger = LogUtil.getLogger();
Logger logger = PluginLogUtils.getLogger();
if (DEBUG.equals(level)) {
if (logger != null && logger.isDebugEnabled()) {
logger.debug(LogUtil.getMsg(msg));
logger.debug(PluginLogUtils.getMsg(msg));
}
} else if (INFO.equals(level)) {
if (logger != null && logger.isInfoEnabled()) {
logger.info(LogUtil.getMsg(msg));
logger.info(PluginLogUtils.getMsg(msg));
}
} else if (WARN.equals(level)) {
if (logger != null && logger.isWarnEnabled()) {
logger.warn(LogUtil.getMsg(msg));
logger.warn(PluginLogUtils.getMsg(msg));
}
} else if (ERROR.equals(level)) {
if (logger != null && logger.isErrorEnabled()) {
logger.error(LogUtil.getMsg(msg));
logger.error(PluginLogUtils.getMsg(msg));
}
} else {
if (logger != null && logger.isErrorEnabled()) {
@ -49,122 +45,122 @@ public class LogUtil {
}
public static void info(Object msg) {
Logger logger = LogUtil.getLogger();
Logger logger = PluginLogUtils.getLogger();
if (logger != null && logger.isInfoEnabled()) {
logger.info(LogUtil.getMsg(msg));
logger.info(PluginLogUtils.getMsg(msg));
System.out.println(msg);
}
}
public static void info(Object msg, Object o1) {
Logger logger = LogUtil.getLogger();
Logger logger = PluginLogUtils.getLogger();
if (logger != null && logger.isInfoEnabled()) {
logger.info(LogUtil.getMsg(msg), o1);
logger.info(PluginLogUtils.getMsg(msg), o1);
}
}
public static void info(Object msg, Object o1, Object o2) {
Logger logger = LogUtil.getLogger();
Logger logger = PluginLogUtils.getLogger();
if (logger != null && logger.isInfoEnabled()) {
logger.info(LogUtil.getMsg(msg), o1, o2);
logger.info(PluginLogUtils.getMsg(msg), o1, o2);
}
}
public static void info(Object msg, Object[] obj) {
Logger logger = LogUtil.getLogger();
Logger logger = PluginLogUtils.getLogger();
if (logger != null && logger.isInfoEnabled()) {
logger.info(LogUtil.getMsg(msg), obj);
logger.info(PluginLogUtils.getMsg(msg), obj);
}
}
public static void debug(Object msg) {
Logger logger = LogUtil.getLogger();
Logger logger = PluginLogUtils.getLogger();
if (logger != null && logger.isDebugEnabled()) {
logger.debug(LogUtil.getMsg(msg));
logger.debug(PluginLogUtils.getMsg(msg));
}
}
public static void debug(Object msg, Object o) {
Logger logger = LogUtil.getLogger();
Logger logger = PluginLogUtils.getLogger();
if (logger != null && logger.isDebugEnabled()) {
logger.debug(LogUtil.getMsg(msg), o);
logger.debug(PluginLogUtils.getMsg(msg), o);
}
}
public static void debug(Object msg, Object o1, Object o2) {
Logger logger = LogUtil.getLogger();
Logger logger = PluginLogUtils.getLogger();
if (logger != null && logger.isDebugEnabled()) {
logger.debug(LogUtil.getMsg(msg), o1, o2);
logger.debug(PluginLogUtils.getMsg(msg), o1, o2);
}
}
public static void debug(Object msg, Object[] obj) {
Logger logger = LogUtil.getLogger();
Logger logger = PluginLogUtils.getLogger();
if (logger != null && logger.isDebugEnabled()) {
logger.debug(LogUtil.getMsg(msg), obj);
logger.debug(PluginLogUtils.getMsg(msg), obj);
}
}
public static void warn(Object msg) {
Logger logger = LogUtil.getLogger();
Logger logger = PluginLogUtils.getLogger();
if (logger != null && logger.isWarnEnabled()) {
logger.warn(LogUtil.getMsg(msg));
logger.warn(PluginLogUtils.getMsg(msg));
}
}
public static void warn(Object msg, Object o) {
Logger logger = LogUtil.getLogger();
Logger logger = PluginLogUtils.getLogger();
if (logger != null && logger.isWarnEnabled()) {
logger.warn(LogUtil.getMsg(msg), o);
logger.warn(PluginLogUtils.getMsg(msg), o);
}
}
public static void warn(Object msg, Object o1, Object o2) {
Logger logger = LogUtil.getLogger();
Logger logger = PluginLogUtils.getLogger();
if (logger != null && logger.isWarnEnabled()) {
logger.warn(LogUtil.getMsg(msg), o1, o2);
logger.warn(PluginLogUtils.getMsg(msg), o1, o2);
}
}
public static void warn(Object msg, Object[] obj) {
Logger logger = LogUtil.getLogger();
Logger logger = PluginLogUtils.getLogger();
if (logger != null && logger.isWarnEnabled()) {
logger.warn(LogUtil.getMsg(msg), obj);
logger.warn(PluginLogUtils.getMsg(msg), obj);
}
}
public static void error(Object msg) {
Logger logger = LogUtil.getLogger();
Logger logger = PluginLogUtils.getLogger();
if (logger != null && logger.isErrorEnabled()) {
logger.error(LogUtil.getMsg(msg));// 并追加方法名称
logger.error(PluginLogUtils.getMsg(msg));// 并追加方法名称
}
}
public static void error(Object msg, Object o) {
Logger logger = LogUtil.getLogger();
Logger logger = PluginLogUtils.getLogger();
if (logger != null && logger.isErrorEnabled()) {
logger.error(LogUtil.getMsg(msg), o);
logger.error(PluginLogUtils.getMsg(msg), o);
}
}
public static void error(Object msg, Object o1, Object o2) {
Logger logger = LogUtil.getLogger();
Logger logger = PluginLogUtils.getLogger();
if (logger != null && logger.isErrorEnabled()) {
logger.error(LogUtil.getMsg(msg), o1, o2);
logger.error(PluginLogUtils.getMsg(msg), o1, o2);
}
}
public static void error(Object msg, Object[] obj) {
Logger logger = LogUtil.getLogger();
Logger logger = PluginLogUtils.getLogger();
if (logger != null && logger.isErrorEnabled()) {
logger.error(LogUtil.getMsg(msg), obj);
logger.error(PluginLogUtils.getMsg(msg), obj);
}
}
public static void error(Object msg, Throwable ex) {
Logger logger = LogUtil.getLogger();
Logger logger = PluginLogUtils.getLogger();
if (logger != null && logger.isErrorEnabled()) {
logger.error(LogUtil.getMsg(msg), ex);
logger.error(PluginLogUtils.getMsg(msg), ex);
}
}
@ -172,9 +168,9 @@ public class LogUtil {
String str = "";
if (msg != null) {
str = LogUtil.getLogMethod() + "[" + msg.toString() + "]";
str = PluginLogUtils.getLogMethod() + "[" + msg.toString() + "]";
} else {
str = LogUtil.getLogMethod() + "[null]";
str = PluginLogUtils.getLogMethod() + "[null]";
}
if (ex != null) {
str += "[" + ex.getMessage() + "]";
@ -184,7 +180,7 @@ public class LogUtil {
}
public static String getMsg(Object msg) {
return LogUtil.getMsg(msg, null);
return PluginLogUtils.getMsg(msg, null);
}
/**
@ -220,40 +216,4 @@ public class LogUtil {
return str;
}
public static String toString(Throwable e) {
StringWriter sw = null;
PrintWriter pw = null;
try {
sw = new StringWriter();
pw = new PrintWriter(sw);
//将出错的栈信息输出到printWriter中
e.printStackTrace(pw);
pw.flush();
sw.flush();
} finally {
if (sw != null) {
try {
sw.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
if (pw != null) {
pw.close();
}
}
return sw.toString();
}
public static String getExceptionDetailsToStr(Exception e) {
StringBuilder sb = new StringBuilder(e.toString());
StackTraceElement[] stackElements = e.getStackTrace();
for (StackTraceElement stackTraceElement : stackElements) {
sb.append(stackTraceElement.toString());
sb.append("\n");
}
sb.append("\n");
return sb.toString();
}
}

View File

@ -0,0 +1,145 @@
package io.metersphere.sdk.util;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
public class DateUtils {
public static final String DATE_PATTERN = "yyyy-MM-dd";
public static final String TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
public static Date getDate(String dateString) throws Exception {
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_PATTERN);
return dateFormat.parse(dateString);
}
public static Date getTime(String timeString) throws Exception {
SimpleDateFormat dateFormat = new SimpleDateFormat(TIME_PATTERN);
return dateFormat.parse(timeString);
}
public static String getDateString(Date date) throws Exception {
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_PATTERN);
return dateFormat.format(date);
}
public static String getDateString(long timeStamp) throws Exception {
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_PATTERN);
return dateFormat.format(timeStamp);
}
public static String getTimeString(Date date) throws Exception {
SimpleDateFormat dateFormat = new SimpleDateFormat(TIME_PATTERN);
return dateFormat.format(date);
}
public static String getTimeString(long timeStamp) {
SimpleDateFormat dateFormat = new SimpleDateFormat(TIME_PATTERN);
return dateFormat.format(timeStamp);
}
public static String getTimeStr(long timeStamp) {
SimpleDateFormat dateFormat = new SimpleDateFormat(TIME_PATTERN);
return dateFormat.format(timeStamp);
}
public static String getDataStr(long timeStamp) {
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_PATTERN);
return dateFormat.format(timeStamp);
}
public static Date dateSum(Date date, int countDays) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_MONTH, countDays);
return calendar.getTime();
}
public static Date dateSum(Date date, int countUnit, int calendarType) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(calendarType, countUnit);
return calendar.getTime();
}
/**
* 获取入参日期所在周的周一周末日期 日期对应的时间为当日的零点
*
* @return Map<String, String>(2); key取值范围firstTime/lastTime
*/
public static Map<String, Date> getWeedFirstTimeAndLastTime(Date date) throws Exception{
Map<String, Date> returnMap = new HashMap<>();
Calendar calendar = Calendar.getInstance();
calendar.setFirstDayOfWeek(Calendar.MONDAY);
int dayWeek = calendar.get(Calendar.DAY_OF_WEEK);
if (dayWeek == 1) {
dayWeek = 8;
}
calendar.add(Calendar.DATE, calendar.getFirstDayOfWeek() - dayWeek);
//第一天的时分秒是 00:00:00 这里直接取日期默认就是零点零分
Date thisWeekFirstTime = getDate(getDateString(calendar.getTime()));
//计算七天过后的日期
calendar.add(Calendar.DATE, 7);
Date nextWeekFirstDay = getDate(getDateString(calendar.getTime()));
Date thisWeekLastTime = getTime(getTimeString(nextWeekFirstDay.getTime() - 1));
returnMap.put("firstTime", thisWeekFirstTime);
returnMap.put("lastTime", thisWeekLastTime);
return returnMap;
}
/**
* 获取当前时间或者当前时间+- 任意天数 时间的时间戳
*
* @param countDays
* @return
*/
public static Long getTimestamp(int countDays) {
Date now = new Date();
return dateSum(now, countDays).getTime() / 1000 * 1000;
}
public static Long getTimestamp(String dateString) throws Exception {
return getDate(dateString).getTime();
}
/**
* 获取当天的起始时间Date
*
* @param time 指定日期 2020-12-13 06:12:42
* @return 当天起始时间 2020-12-13 00:00:00
* @throws Exception
*/
public static Date getDayStartTime(Date time) throws Exception {
return getDate(getDateString(time));
}
public static long getDailyStartTime() {
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTimeInMillis();
}
public static long getDailyEndTime() {
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.set(Calendar.HOUR_OF_DAY, 23);
calendar.set(Calendar.MINUTE, 59);
calendar.set(Calendar.SECOND, 59);
calendar.set(Calendar.MILLISECOND, 999);
return calendar.getTimeInMillis();
}
}

View File

@ -0,0 +1,167 @@
package io.metersphere.sdk.util;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
public class LogUtils {
//日志工具类
public static final String DEBUG = "DEBUG";
public static final String INFO = "INFO";
public static final String WARN = "WARN";
public static final String ERROR = "ERROR";
public static void writeLog(Object msg, String level, Logger logger) {
if (logger != null && logger.isInfoEnabled()) {
switch (level) {
case DEBUG -> logger.debug(LogUtils.getMsg(msg));
case INFO -> logger.info(LogUtils.getMsg(msg));
case WARN -> logger.warn(LogUtils.getMsg(msg));
case ERROR -> logger.error(LogUtils.getMsg(msg));
default -> logger.error(StringUtils.EMPTY);
}
}
}
public static void info(Object msg, Logger logger) {
if (logger != null && logger.isInfoEnabled()) {
logger.info(LogUtils.getMsg(msg));
}
}
public static void info(Object msg, Object o1, Logger logger) {
if (logger != null && logger.isInfoEnabled()) {
logger.info(LogUtils.getMsg(msg), o1);
}
}
public static void info(Object msg, Object o1, Object o2, Logger logger) {
if (logger != null && logger.isInfoEnabled()) {
logger.info(LogUtils.getMsg(msg), o1, o2);
}
}
public static void info(Object msg, Object[] obj, Logger logger) {
if (logger != null && logger.isInfoEnabled()) {
logger.info(LogUtils.getMsg(msg), obj);
}
}
public static void debug(Object msg, Logger logger) {
if (logger != null && logger.isDebugEnabled()) {
logger.debug(LogUtils.getMsg(msg));
}
}
public static void debug(Object msg, Object o, Logger logger) {
if (logger != null && logger.isDebugEnabled()) {
logger.debug(LogUtils.getMsg(msg), o);
}
}
public static void debug(Object msg, Object o1, Object o2, Logger logger) {
if (logger != null && logger.isDebugEnabled()) {
logger.debug(LogUtils.getMsg(msg), o1, o2);
}
}
public static void debug(Object msg, Object[] obj, Logger logger) {
if (logger != null && logger.isDebugEnabled()) {
logger.debug(LogUtils.getMsg(msg), obj);
}
}
public static void warn(Object msg, Logger logger) {
if (logger != null && logger.isWarnEnabled()) {
logger.warn(LogUtils.getMsg(msg));
}
}
public static void warn(Object msg, Object o, Logger logger) {
if (logger != null && logger.isWarnEnabled()) {
logger.warn(LogUtils.getMsg(msg), o);
}
}
public static void warn(Object msg, Object o1, Object o2, Logger logger) {
if (logger != null && logger.isWarnEnabled()) {
logger.warn(LogUtils.getMsg(msg), o1, o2);
}
}
public static void warn(Object msg, Object[] obj, Logger logger) {
if (logger != null && logger.isWarnEnabled()) {
logger.warn(LogUtils.getMsg(msg), obj);
}
}
public static void error(Object msg, Logger logger) {
if (logger != null && logger.isErrorEnabled()) {
logger.error(LogUtils.getMsg(msg));// 并追加方法名称
}
}
public static void error(Throwable e, Logger logger) {
if (logger != null && logger.isErrorEnabled()) {
logger.error(LogUtils.getMsg(e), e);// 同时打印错误堆栈信息
}
}
public static void error(Object msg, Object o, Logger logger) {
if (logger != null && logger.isErrorEnabled()) {
logger.error(LogUtils.getMsg(msg), o);
}
}
public static void error(Object msg, Object o1, Object o2, Logger logger) {
if (logger != null && logger.isErrorEnabled()) {
logger.error(LogUtils.getMsg(msg), o1, o2);
}
}
public static void error(Object msg, Object[] obj, Logger logger) {
if (logger != null && logger.isErrorEnabled()) {
logger.error(LogUtils.getMsg(msg), obj);
}
}
public static void error(Object msg, Throwable ex, Logger logger) {
if (logger != null && logger.isErrorEnabled()) {
logger.error(LogUtils.getMsg(msg), ex);
}
}
public static String getMsg(Object msg, Throwable ex) {
String str = "";
if (msg != null) {
str = LogUtils.getLogMethod() + "[" + msg + "]";
} else {
str = LogUtils.getLogMethod() + "[null]";
}
if (ex != null) {
str += "[" + ex.getMessage() + "]";
}
return str;
}
public static String getMsg(Object msg) {
return LogUtils.getMsg(msg, null);
}
/**
* 得到调用方法名称
*
* @return
*/
private static String getLogMethod() {
String str = "";
StackTraceElement[] stack = (new Throwable()).getStackTrace();
if (stack.length > 4) {
StackTraceElement ste = stack[4];
str = "Method[" + ste.getMethodName() + "]";// 方法名称
}
return str;
}
}

View File

@ -0,0 +1,44 @@
package io.metersphere.api.jmeter;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.classic.spi.StackTraceElementProxy;
import ch.qos.logback.core.UnsynchronizedAppenderBase;
import io.metersphere.api.utils.ApiLogUtils;
import io.metersphere.api.utils.FixedCapacityUtils;
import io.metersphere.sdk.util.DateUtils;
import io.metersphere.sdk.util.LogUtils;
import org.apache.commons.lang3.StringUtils;
public class JMeterLoggerAppender extends UnsynchronizedAppenderBase<ILoggingEvent> {
private final static String THREAD_SPLIT = " ";
@Override
public void append(ILoggingEvent event) {
try {
if (!event.getLevel().levelStr.equals(LogUtils.DEBUG) && StringUtils.isNotEmpty(event.getThreadName())) {
StringBuffer message = new StringBuffer();
String threadName = StringUtils.substringBeforeLast(event.getThreadName(), THREAD_SPLIT);
message.append(DateUtils.getTimeStr(event.getTimeStamp())).append(StringUtils.SPACE)
.append(event.getLevel()).append(StringUtils.SPACE)
.append(event.getThreadName()).append(StringUtils.SPACE)
.append(event.getFormattedMessage()).append(StringUtils.LF);
if (event.getThrowableProxy() != null) {
message.append(event.getThrowableProxy().getMessage()).append(StringUtils.LF);
message.append(event.getThrowableProxy().getClassName()).append(StringUtils.LF);
if (event.getThrowableProxy().getStackTraceElementProxyArray() != null) {
for (StackTraceElementProxy stackTraceElementProxy : event.getThrowableProxy().getStackTraceElementProxyArray()) {
message.append(" ").append(stackTraceElementProxy.getSTEAsString()).append(StringUtils.LF);
}
}
}
if (message != null && !message.toString().contains("java.net.UnknownHostException")
&& FixedCapacityUtils.containsKey(threadName)) {
FixedCapacityUtils.get(threadName).append(message);
}
}
} catch (Exception e) {
ApiLogUtils.error(e);
}
}
}

View File

@ -0,0 +1,93 @@
package io.metersphere.api.utils;
import io.metersphere.sdk.util.LogUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ApiLogUtils extends LogUtils {
/**
* 初始化日志
*
* @return
*/
public static Logger getLogger() {
return LoggerFactory.getLogger("api-test");
}
public static void writeLog(Object msg, String level) {
writeLog(msg, level, getLogger());
}
public static void info(Object msg) {
info(msg, getLogger());
}
public static void info(Object msg, Object o1) {
info(msg, o1, getLogger().atError());
}
public static void info(Object msg, Object o1, Object o2) {
info(msg, o1, o2, getLogger());
}
public static void info(Object msg, Object[] obj) {
info(msg, obj, getLogger());
}
public static void debug(Object msg) {
debug(msg, getLogger());
}
public static void debug(Object msg, Object o) {
debug(msg, o, getLogger());
}
public static void debug(Object msg, Object o1, Object o2) {
debug(msg, o1, o2, getLogger());
}
public static void debug(Object msg, Object[] obj) {
debug(msg, obj, getLogger());
}
public static void warn(Object msg) {
warn(msg, getLogger());
}
public static void warn(Object msg, Object o) {
warn(msg, o, getLogger());
}
public static void warn(Object msg, Object o1, Object o2) {
warn(msg, o1, o2, getLogger());
}
public static void warn(Object msg, Object[] obj) {
warn(msg, obj, getLogger());
}
public static void error(Object msg) {
error(msg, getLogger());
}
public static void error(Throwable e) {
error(e, getLogger());
}
public static void error(Object msg, Object o) {
error(msg, o, getLogger());
}
public static void error(Object msg, Object o1, Object o2) {
error(msg, o1, o2, getLogger());
}
public static void error(Object msg, Object[] obj) {
error(msg, obj, getLogger());
}
public static void error(Object msg, Throwable ex) {
error(msg, ex, getLogger());
}
}

View File

@ -0,0 +1,48 @@
package io.metersphere.api.utils;
import org.apache.commons.lang3.StringUtils;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
public class FixedCapacityUtils {
private static Map<String, StringBuffer> fixedCapacityCache = Collections.synchronizedMap(new LRUHashMap<>());
public static StringBuffer get(String key) {
return fixedCapacityCache.get(key);
}
public static boolean containsKey(String key) {
if (StringUtils.isEmpty(key)) {
return false;
}
return fixedCapacityCache.containsKey(key);
}
public static void put(String key, StringBuffer value) {
if (!fixedCapacityCache.containsKey(key)) {
fixedCapacityCache.put(key, value);
}
}
public static void remove(String key) {
if (fixedCapacityCache.containsKey(key)) {
fixedCapacityCache.remove(key);
}
}
public static int size() {
return fixedCapacityCache.size();
}
static class LRUHashMap<K, V> extends LinkedHashMap<K, V> {
private int capacity = 3000;
@Override
protected boolean removeEldestEntry(Map.Entry<K, V> eldest) {
return size() > capacity;
}
}
}

View File

@ -0,0 +1,93 @@
package io.metersphere.load.util;
import io.metersphere.sdk.util.LogUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class LoadLogUtils extends LogUtils {
/**
* 初始化日志
*
* @return
*/
public static Logger getLogger() {
return LoggerFactory.getLogger("load-test");
}
public static void writeLog(Object msg, String level) {
writeLog(msg, level, getLogger());
}
public static void info(Object msg) {
info(msg, getLogger());
}
public static void info(Object msg, Object o1) {
info(msg, o1, getLogger().atError());
}
public static void info(Object msg, Object o1, Object o2) {
info(msg, o1, o2, getLogger());
}
public static void info(Object msg, Object[] obj) {
info(msg, obj, getLogger());
}
public static void debug(Object msg) {
debug(msg, getLogger());
}
public static void debug(Object msg, Object o) {
debug(msg, o, getLogger());
}
public static void debug(Object msg, Object o1, Object o2) {
debug(msg, o1, o2, getLogger());
}
public static void debug(Object msg, Object[] obj) {
debug(msg, obj, getLogger());
}
public static void warn(Object msg) {
warn(msg, getLogger());
}
public static void warn(Object msg, Object o) {
warn(msg, o, getLogger());
}
public static void warn(Object msg, Object o1, Object o2) {
warn(msg, o1, o2, getLogger());
}
public static void warn(Object msg, Object[] obj) {
warn(msg, obj, getLogger());
}
public static void error(Object msg) {
error(msg, getLogger());
}
public static void error(Throwable e) {
error(e, getLogger());
}
public static void error(Object msg, Object o) {
error(msg, o, getLogger());
}
public static void error(Object msg, Object o1, Object o2) {
error(msg, o1, o2, getLogger());
}
public static void error(Object msg, Object[] obj) {
error(msg, obj, getLogger());
}
public static void error(Object msg, Throwable ex) {
error(msg, ex, getLogger());
}
}

View File

@ -0,0 +1,87 @@
package io.metersphere.project.util;
import io.metersphere.sdk.util.LogUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ProjectLogUtils extends LogUtils {
public static Logger getLogger() {
return LoggerFactory.getLogger("project-management");
}
public static void writeLog(Object msg, String level) {
writeLog(msg, level, getLogger());
}
public static void info(Object msg) {
info(msg, getLogger());
}
public static void info(Object msg, Object o1) {
info(msg, o1, getLogger().atError());
}
public static void info(Object msg, Object o1, Object o2) {
info(msg, o1, o2, getLogger());
}
public static void info(Object msg, Object[] obj) {
info(msg, obj, getLogger());
}
public static void debug(Object msg) {
debug(msg, getLogger());
}
public static void debug(Object msg, Object o) {
debug(msg, o, getLogger());
}
public static void debug(Object msg, Object o1, Object o2) {
debug(msg, o1, o2, getLogger());
}
public static void debug(Object msg, Object[] obj) {
debug(msg, obj, getLogger());
}
public static void warn(Object msg) {
warn(msg, getLogger());
}
public static void warn(Object msg, Object o) {
warn(msg, o, getLogger());
}
public static void warn(Object msg, Object o1, Object o2) {
warn(msg, o1, o2, getLogger());
}
public static void warn(Object msg, Object[] obj) {
warn(msg, obj, getLogger());
}
public static void error(Object msg) {
error(msg, getLogger());
}
public static void error(Throwable e) {
error(e, getLogger());
}
public static void error(Object msg, Object o) {
error(msg, o, getLogger());
}
public static void error(Object msg, Object o1, Object o2) {
error(msg, o1, o2, getLogger());
}
public static void error(Object msg, Object[] obj) {
error(msg, obj, getLogger());
}
public static void error(Object msg, Throwable ex) {
error(msg, ex, getLogger());
}
}

View File

@ -0,0 +1,93 @@
package io.metersphere.system.util;
import io.metersphere.sdk.util.LogUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SystemLogUtils extends LogUtils {
/**
* 初始化日志
*
* @return
*/
public static Logger getLogger() {
return LoggerFactory.getLogger("system-setting");
}
public static void writeLog(Object msg, String level) {
writeLog(msg, level, getLogger());
}
public static void info(Object msg) {
info(msg, getLogger());
}
public static void info(Object msg, Object o1) {
info(msg, o1, getLogger().atError());
}
public static void info(Object msg, Object o1, Object o2) {
info(msg, o1, o2, getLogger());
}
public static void info(Object msg, Object[] obj) {
info(msg, obj, getLogger());
}
public static void debug(Object msg) {
debug(msg, getLogger());
}
public static void debug(Object msg, Object o) {
debug(msg, o, getLogger());
}
public static void debug(Object msg, Object o1, Object o2) {
debug(msg, o1, o2, getLogger());
}
public static void debug(Object msg, Object[] obj) {
debug(msg, obj, getLogger());
}
public static void warn(Object msg) {
warn(msg, getLogger());
}
public static void warn(Object msg, Object o) {
warn(msg, o, getLogger());
}
public static void warn(Object msg, Object o1, Object o2) {
warn(msg, o1, o2, getLogger());
}
public static void warn(Object msg, Object[] obj) {
warn(msg, obj, getLogger());
}
public static void error(Object msg) {
error(msg, getLogger());
}
public static void error(Throwable e) {
error(e, getLogger());
}
public static void error(Object msg, Object o) {
error(msg, o, getLogger());
}
public static void error(Object msg, Object o1, Object o2) {
error(msg, o1, o2, getLogger());
}
public static void error(Object msg, Object[] obj) {
error(msg, obj, getLogger());
}
public static void error(Object msg, Throwable ex) {
error(msg, ex, getLogger());
}
}

View File

@ -0,0 +1,93 @@
package io.metersphere.plan.util;
import io.metersphere.sdk.util.LogUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class PlanLogUtils extends LogUtils {
/**
* 初始化日志
*
* @return
*/
public static Logger getLogger() {
return LoggerFactory.getLogger("test-plan");
}
public static void writeLog(Object msg, String level) {
writeLog(msg, level, getLogger());
}
public static void info(Object msg) {
info(msg, getLogger());
}
public static void info(Object msg, Object o1) {
info(msg, o1, getLogger().atError());
}
public static void info(Object msg, Object o1, Object o2) {
info(msg, o1, o2, getLogger());
}
public static void info(Object msg, Object[] obj) {
info(msg, obj, getLogger());
}
public static void debug(Object msg) {
debug(msg, getLogger());
}
public static void debug(Object msg, Object o) {
debug(msg, o, getLogger());
}
public static void debug(Object msg, Object o1, Object o2) {
debug(msg, o1, o2, getLogger());
}
public static void debug(Object msg, Object[] obj) {
debug(msg, obj, getLogger());
}
public static void warn(Object msg) {
warn(msg, getLogger());
}
public static void warn(Object msg, Object o) {
warn(msg, o, getLogger());
}
public static void warn(Object msg, Object o1, Object o2) {
warn(msg, o1, o2, getLogger());
}
public static void warn(Object msg, Object[] obj) {
warn(msg, obj, getLogger());
}
public static void error(Object msg) {
error(msg, getLogger());
}
public static void error(Throwable e) {
error(e, getLogger());
}
public static void error(Object msg, Object o) {
error(msg, o, getLogger());
}
public static void error(Object msg, Object o1, Object o2) {
error(msg, o1, o2, getLogger());
}
public static void error(Object msg, Object[] obj) {
error(msg, obj, getLogger());
}
public static void error(Object msg, Throwable ex) {
error(msg, ex, getLogger());
}
}

View File

@ -0,0 +1,93 @@
package io.metersphere.track.util;
import io.metersphere.sdk.util.LogUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TrackLogUtils extends LogUtils {
/**
* 初始化日志
*
* @return
*/
public static Logger getLogger() {
return LoggerFactory.getLogger("test-track");
}
public static void writeLog(Object msg, String level) {
writeLog(msg, level, getLogger());
}
public static void info(Object msg) {
info(msg, getLogger());
}
public static void info(Object msg, Object o1) {
info(msg, o1, getLogger().atError());
}
public static void info(Object msg, Object o1, Object o2) {
info(msg, o1, o2, getLogger());
}
public static void info(Object msg, Object[] obj) {
info(msg, obj, getLogger());
}
public static void debug(Object msg) {
debug(msg, getLogger());
}
public static void debug(Object msg, Object o) {
debug(msg, o, getLogger());
}
public static void debug(Object msg, Object o1, Object o2) {
debug(msg, o1, o2, getLogger());
}
public static void debug(Object msg, Object[] obj) {
debug(msg, obj, getLogger());
}
public static void warn(Object msg) {
warn(msg, getLogger());
}
public static void warn(Object msg, Object o) {
warn(msg, o, getLogger());
}
public static void warn(Object msg, Object o1, Object o2) {
warn(msg, o1, o2, getLogger());
}
public static void warn(Object msg, Object[] obj) {
warn(msg, obj, getLogger());
}
public static void error(Object msg) {
error(msg, getLogger());
}
public static void error(Throwable e) {
error(e, getLogger());
}
public static void error(Object msg, Object o) {
error(msg, o, getLogger());
}
public static void error(Object msg, Object o1, Object o2) {
error(msg, o1, o2, getLogger());
}
public static void error(Object msg, Object[] obj) {
error(msg, obj, getLogger());
}
public static void error(Object msg, Throwable ex) {
error(msg, ex, getLogger());
}
}

View File

@ -0,0 +1,93 @@
package io.metersphere.ui.util;
import io.metersphere.sdk.util.LogUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class UiLogUtils extends LogUtils {
/**
* 初始化日志
*
* @return
*/
public static Logger getLogger() {
return LoggerFactory.getLogger("ui-test");
}
public static void writeLog(Object msg, String level) {
writeLog(msg, level, getLogger());
}
public static void info(Object msg) {
info(msg, getLogger());
}
public static void info(Object msg, Object o1) {
info(msg, o1, getLogger().atError());
}
public static void info(Object msg, Object o1, Object o2) {
info(msg, o1, o2, getLogger());
}
public static void info(Object msg, Object[] obj) {
info(msg, obj, getLogger());
}
public static void debug(Object msg) {
debug(msg, getLogger());
}
public static void debug(Object msg, Object o) {
debug(msg, o, getLogger());
}
public static void debug(Object msg, Object o1, Object o2) {
debug(msg, o1, o2, getLogger());
}
public static void debug(Object msg, Object[] obj) {
debug(msg, obj, getLogger());
}
public static void warn(Object msg) {
warn(msg, getLogger());
}
public static void warn(Object msg, Object o) {
warn(msg, o, getLogger());
}
public static void warn(Object msg, Object o1, Object o2) {
warn(msg, o1, o2, getLogger());
}
public static void warn(Object msg, Object[] obj) {
warn(msg, obj, getLogger());
}
public static void error(Object msg) {
error(msg, getLogger());
}
public static void error(Throwable e) {
error(e, getLogger());
}
public static void error(Object msg, Object o) {
error(msg, o, getLogger());
}
public static void error(Object msg, Object o1, Object o2) {
error(msg, o1, o2, getLogger());
}
public static void error(Object msg, Object[] obj) {
error(msg, obj, getLogger());
}
public static void error(Object msg, Throwable ex) {
error(msg, ex, getLogger());
}
}

View File

@ -0,0 +1,93 @@
package io.metersphere.workstation.utils;
import io.metersphere.sdk.util.LogUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class WorkstationLogUtils extends LogUtils {
/**
* 初始化日志
*
* @return
*/
public static Logger getLogger() {
return LoggerFactory.getLogger("workstation");
}
public static void writeLog(Object msg, String level) {
writeLog(msg, level, getLogger());
}
public static void info(Object msg) {
info(msg, getLogger());
}
public static void info(Object msg, Object o1) {
info(msg, o1, getLogger().atError());
}
public static void info(Object msg, Object o1, Object o2) {
info(msg, o1, o2, getLogger());
}
public static void info(Object msg, Object[] obj) {
info(msg, obj, getLogger());
}
public static void debug(Object msg) {
debug(msg, getLogger());
}
public static void debug(Object msg, Object o) {
debug(msg, o, getLogger());
}
public static void debug(Object msg, Object o1, Object o2) {
debug(msg, o1, o2, getLogger());
}
public static void debug(Object msg, Object[] obj) {
debug(msg, obj, getLogger());
}
public static void warn(Object msg) {
warn(msg, getLogger());
}
public static void warn(Object msg, Object o) {
warn(msg, o, getLogger());
}
public static void warn(Object msg, Object o1, Object o2) {
warn(msg, o1, o2, getLogger());
}
public static void warn(Object msg, Object[] obj) {
warn(msg, obj, getLogger());
}
public static void error(Object msg) {
error(msg, getLogger());
}
public static void error(Throwable e) {
error(e, getLogger());
}
public static void error(Object msg, Object o) {
error(msg, o, getLogger());
}
public static void error(Object msg, Object o1, Object o2) {
error(msg, o1, o2, getLogger());
}
public static void error(Object msg, Object[] obj) {
error(msg, obj, getLogger());
}
public static void error(Object msg, Throwable ex) {
error(msg, ex, getLogger());
}
}