Skip to content

Commit e922674

Browse files
committed
add log level
1 parent 2018f2a commit e922674

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

core/src/main/java/com/dtstack/flink/sql/Main.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package com.dtstack.flink.sql;
2121

2222

23+
2324
import com.dtstack.flink.sql.exec.ExecuteProcessHelper;
2425
import com.dtstack.flink.sql.exec.ParamsInfo;
2526
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

core/src/main/java/com/dtstack/flink/sql/exec/ExecuteProcessHelper.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
package com.dtstack.flink.sql.exec;
2020

21+
import ch.qos.logback.classic.Level;
22+
import ch.qos.logback.classic.LoggerContext;
2123
import com.dtstack.flink.sql.classloader.ClassLoaderManager;
2224
import com.dtstack.flink.sql.config.CalciteConfig;
2325
import com.dtstack.flink.sql.enums.ClusterMode;
@@ -108,6 +110,7 @@ public static ParamsInfo parseParams(String[] args) throws Exception {
108110
String remoteSqlPluginPath = options.getRemoteSqlPluginPath();
109111
String pluginLoadMode = options.getPluginLoadMode();
110112
String deployMode = options.getMode();
113+
String logLevel = options.getLogLevel();
111114

112115
Preconditions.checkArgument(checkRemoteSqlPluginPath(remoteSqlPluginPath, deployMode, pluginLoadMode),
113116
"Non-local mode or shipfile deployment mode, remoteSqlPluginPath is required");
@@ -125,6 +128,7 @@ public static ParamsInfo parseParams(String[] args) throws Exception {
125128
.setDeployMode(deployMode)
126129
.setConfProp(confProperties)
127130
.setJarUrlList(jarURList)
131+
.setLogLevel(logLevel)
128132
.build();
129133

130134
}
@@ -150,6 +154,8 @@ public static StreamExecutionEnvironment getStreamExecution(ParamsInfo paramsInf
150154
StreamTableEnvironment tableEnv = StreamTableEnvironment.create(env);
151155
StreamQueryConfig streamQueryConfig = StreamEnvConfigManager.getStreamQueryConfig(tableEnv, paramsInfo.getConfProp());
152156

157+
setLogLevel(paramsInfo.getLogLevel());
158+
153159
SqlParser.setLocalSqlPluginRoot(paramsInfo.getLocalSqlPluginPath());
154160
SqlTree sqlTree = SqlParser.parseSql(paramsInfo.getSql());
155161

@@ -341,4 +347,12 @@ public static StreamExecutionEnvironment getStreamExeEnv(Properties confProperti
341347
StreamEnvConfigManager.streamExecutionEnvironmentConfig(env, confProperties);
342348
return env;
343349
}
350+
351+
private static void setLogLevel(String level){
352+
LoggerContext loggerContext= (LoggerContext) LoggerFactory.getILoggerFactory();
353+
//设置全局日志级别
354+
ch.qos.logback.classic.Logger logger = loggerContext.getLogger("root");
355+
logger.setLevel(Level.toLevel(level, Level.INFO));
356+
}
357+
344358
}

core/src/main/java/com/dtstack/flink/sql/exec/ParamsInfo.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,19 @@ public class ParamsInfo {
3838
private String remoteSqlPluginPath;
3939
private String pluginLoadMode;
4040
private String deployMode;
41+
private String logLevel;
4142
private Properties confProp;
4243

4344
public ParamsInfo(String sql, String name, List<URL> jarUrlList, String localSqlPluginPath,
44-
String remoteSqlPluginPath, String pluginLoadMode, String deployMode, Properties confProp) {
45+
String remoteSqlPluginPath, String pluginLoadMode, String deployMode, String logLevel, Properties confProp) {
4546
this.sql = sql;
4647
this.name = name;
4748
this.jarUrlList = jarUrlList;
4849
this.localSqlPluginPath = localSqlPluginPath;
4950
this.remoteSqlPluginPath = remoteSqlPluginPath;
5051
this.pluginLoadMode = pluginLoadMode;
5152
this.deployMode = deployMode;
53+
this.logLevel = logLevel;
5254
this.confProp = confProp;
5355
}
5456

@@ -84,6 +86,10 @@ public Properties getConfProp() {
8486
return confProp;
8587
}
8688

89+
public String getLogLevel() {
90+
return logLevel;
91+
}
92+
8793
@Override
8894
public String toString() {
8995
return "ParamsInfo{" +
@@ -94,6 +100,7 @@ public String toString() {
94100
", remoteSqlPluginPath='" + remoteSqlPluginPath + '\'' +
95101
", pluginLoadMode='" + pluginLoadMode + '\'' +
96102
", deployMode='" + deployMode + '\'' +
103+
", logLevel='" + logLevel + '\'' +
97104
", confProp=" + confProp +
98105
'}';
99106
}
@@ -114,6 +121,7 @@ public static class Builder {
114121
private String remoteSqlPluginPath;
115122
private String pluginLoadMode;
116123
private String deployMode;
124+
private String logLevel;
117125
private Properties confProp;
118126

119127

@@ -152,14 +160,19 @@ public ParamsInfo.Builder setDeployMode(String deployMode) {
152160
return this;
153161
}
154162

163+
public ParamsInfo.Builder setLogLevel(String logLevel) {
164+
this.logLevel = logLevel;
165+
return this;
166+
}
167+
155168
public ParamsInfo.Builder setConfProp(Properties confProp) {
156169
this.confProp = confProp;
157170
return this;
158171
}
159172

160173
public ParamsInfo build() {
161174
return new ParamsInfo(sql, name, jarUrlList, localSqlPluginPath,
162-
remoteSqlPluginPath, pluginLoadMode, deployMode, confProp);
175+
remoteSqlPluginPath, pluginLoadMode, deployMode, logLevel, confProp);
163176
}
164177
}
165178
}

core/src/main/java/com/dtstack/flink/sql/option/Options.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public class Options {
6969
@OptionRequired(description = "plugin load mode, by classpath or shipfile")
7070
private String pluginLoadMode = EPluginLoadMode.CLASSPATH.name();
7171

72-
private String logLevel = "logLevel";
72+
private String logLevel;
7373

7474
public String getMode() {
7575
return mode;

0 commit comments

Comments
 (0)