Skip to content

Commit

Permalink
resolve comment
Browse files Browse the repository at this point in the history
  • Loading branch information
wangcheng15 committed Sep 2, 2022
1 parent 69b4afc commit 8f32fb6
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ class RDSchema(dbType: String) {
f.toString.toInt
} catch {
case e: Exception =>
if (log.isDebugEnabled()) {
log.debug("extractfieldSize Error: {}", e)
}
log.error("ExtractfieldSize Error: {}", e)
0
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ class SelectSuggesterTest extends BaseTest with Logging {
val tokens = getMLSQLTokens(sql)

val suggester = new SelectSuggester(context, tokens, TokenPos(0, TokenPosType.NEXT, 0))
log.info("=======")
if (log.isInfoEnabled()) {
log.info("=======")
log.info(suggester.suggest().toString())
}
assert(suggester.suggest().head.name=="b")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class TableStructureTest extends BaseTest with Logging {
val root = suggester.sqlAST
root.visitDown(0) { case (ast, level) =>
if (log.isInfoEnabled()) {
log.info(ast.name(suggester.tokens) + " " + ast.output(suggester.tokens))
log.info(s"${ast.name(suggester.tokens)} ${ast.output(suggester.tokens)}")
}
}

Expand All @@ -104,7 +104,7 @@ class TableStructureTest extends BaseTest with Logging {
val root = suggester.sqlAST
root.visitDown(0) { case (ast, level) =>
if (log.isInfoEnabled()) {
log.info(ast.name(suggester.tokens) + " " + ast.output(suggester.tokens))
log.info(s"${ast.name(suggester.tokens)} ${ast.output(suggester.tokens)}")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ class RestIndexerMeta(url: String, token: String,timeout:Int=2000) extends MLSQL
JSONTool.parseJson[Map[MlsqlOriTable, List[MlsqlIndexerItem]]](value)
} catch {
case e: Exception =>
if (log.isDebugEnabled) {
log.debug("fetchIndexers Error: {}", e)
}
log.error("FetchIndexers Error: {}", e)
Map()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ object AllocateService extends Logging {
}
} catch {
case e: Exception =>
if (log.isDebugEnabled()) {
log.debug("run Error: {}", e)
}
log.error("Run Error: {}", e)
//catch all ,so the scheduler will not been stopped by exception
}
}
Expand Down
13 changes: 6 additions & 7 deletions streamingpro-commons/src/main/java/streaming/common/zk/Path.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

package streaming.common.zk;

import org.apache.log4j.Logger;
import net.csdn.common.logging.CSLogger;
import net.csdn.common.logging.Loggers;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -28,7 +29,7 @@
*/
public class Path {

private static Logger logger = Logger.getLogger(Path.class);
private static CSLogger logger = Loggers.getLogger(Path.class);

private List<String> detail ;

Expand Down Expand Up @@ -122,11 +123,9 @@ public static void main(String[] args) {
Path p = new Path("/video/_index/pid");
if (logger.isInfoEnabled()) {
logger.info(
String.format(
"Path: %s \n ParentPath: %s \n ",
p.getPathString(),
p.getParentPath().getPathString()
)
"Path: {} \n ParentPath: {} \n ",
p.getPathString(),
p.getParentPath().getPathString()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@
package streaming.common.zk;

import com.google.inject.Inject;
import net.csdn.common.logging.CSLogger;
import net.csdn.common.logging.Loggers;
import net.csdn.common.settings.Settings;
import org.I0Itec.zkclient.IZkDataListener;
import org.apache.log4j.Logger;

/**
* 7/7/16 WilliamZhu([email protected])
*/
public class ZKClient {
private Logger logger = Logger.getLogger(ZKClient.class);
private CSLogger logger = Loggers.getLogger(ZKClient.class);
private ZKConfUtil zkConfUtil;

@Inject
Expand Down Expand Up @@ -129,16 +130,7 @@ public boolean addListenerAndInit(String confName, final ConfCallBack confCallBa
confCallBack.setConf(zkConfUtil.getConf(data));

} catch (Exception e) {
if (logger.isDebugEnabled()) {
logger.debug(
String.format(
"addListenerAndInit Error!!!\n confName: %s \n confCallBack: %s \n exception: %s",
confName,
confCallBack,
e
)
);
}
logger.error("Error: {}", e);
}


Expand Down Expand Up @@ -179,7 +171,7 @@ public void main(String[] args) throws InterruptedException {
@Override
public void setConf(String conf) {
if (logger.isInfoEnabled()) {
logger.info(String.format("conf: %s", conf));
logger.info("conf: {}", conf);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void checkAndAddPath(Path path) {

checkAndAddPath(path.getParentPath());
if (logger.isInfoEnabled()) {
logger.info("add path {}", p);
logger.info("Add path {}", p);
}
client.createPersistent(p);
}
Expand Down Expand Up @@ -222,9 +222,7 @@ public void main(String[] args) throws InterruptedException {
String dir = "/lock/127.0.0.1";

if (!ifExist(dir)) {
if (logger.isInfoEnabled()) {
logger.info("create dir");
}
logger.info("create dir");

if (!ifExist("/lock")) {

Expand All @@ -236,7 +234,7 @@ public void main(String[] args) throws InterruptedException {
String path = client.createEphemeralSequential(dir, null);

if (logger.isInfoEnabled()) {
logger.info(String.format("path: %s", path));
logger.info("path: {}", path);
}

for (String l : client.getChildren(dir)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

package tech.mlsql.ets.hdfs;

import net.csdn.common.logging.CSLogger;
import net.csdn.common.logging.Loggers;
import org.apache.commons.lang.WordUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
Expand All @@ -43,7 +45,7 @@
*/
public class WowFsShell extends Configured implements Tool {

static final Log LOG = LogFactory.getLog(WowFsShell.class);
static final CSLogger LOG = Loggers.getLogger(WowFsShell.class);

private static final int MAX_LINE_WIDTH = 80;

Expand All @@ -57,8 +59,6 @@ public class WowFsShell extends Configured implements Tool {
public final PrintStream out = new PrintStream(outS);
public final PrintStream error = new PrintStream(errorS);

private Logger log = Logger.getLogger(this.getClass());

public String getOut() {
return _out(outS);
}
Expand All @@ -69,9 +69,7 @@ public String _out(ByteArrayOutputStream wow) {
wow.reset();
return temp;
} catch (Exception e) {
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("_out Error!!! \n exception: %s",e));
}
LOG.error("Error: {}",e);
}
return null;
}
Expand Down Expand Up @@ -230,8 +228,8 @@ private void printInfo(PrintStream out, String cmd, boolean showHelp) {
} else {
// display help or usage for all commands
out.println(usagePrefix);
if (log.isInfoEnabled()) {
log.info(usagePrefix);
if (LOG.isInfoEnabled()) {
LOG.info(usagePrefix);
}

// display list of short usages
Expand All @@ -242,7 +240,7 @@ private void printInfo(PrintStream out, String cmd, boolean showHelp) {
String msg = "\t[" + instance.getUsage() + "]";
out.println(msg);
instances.add(instance);
log.info(msg);
LOG.info(msg);
}
}
// display long descriptions for each command
Expand All @@ -260,16 +258,16 @@ private void printInfo(PrintStream out, String cmd, boolean showHelp) {
private void printInstanceUsage(PrintStream out, Command instance) {
String msg = usagePrefix + " " + instance.getUsage();
out.println(msg);
if (log.isInfoEnabled()) {
log.info(msg);
if (LOG.isInfoEnabled()) {
LOG.info(msg);
}
}

private void printInstanceHelp(PrintStream out, Command instance) {
String msg = instance.getUsage() + " :";
out.println(msg);
if (log.isInfoEnabled()) {
log.info(msg);
if (LOG.isInfoEnabled()) {
LOG.info(msg);
}
TableListing listing = null;
final String prefix = " ";
Expand All @@ -290,8 +288,8 @@ private void printInstanceHelp(PrintStream out, Command instance) {
for (String listingLine : listing.toString().split("\n")) {
String listingMsg = prefix + listingLine;
out.println(listingMsg);
if (log.isInfoEnabled()) {
log.info(listingMsg);
if (LOG.isInfoEnabled()) {
LOG.info(listingMsg);
}
}
listing = null;
Expand All @@ -301,8 +299,8 @@ private void printInstanceHelp(PrintStream out, Command instance) {
line, MAX_LINE_WIDTH, "\n", true).split("\n")) {
String descMsg = prefix + descLine;
out.println(descMsg);
if (log.isInfoEnabled()) {
log.info(descMsg);
if (LOG.isInfoEnabled()) {
LOG.info(descMsg);
}
}
}
Expand All @@ -311,8 +309,8 @@ private void printInstanceHelp(PrintStream out, Command instance) {
for (String listingLine : listing.toString().split("\n")) {
String listingLineMsg = prefix + listingLine;
out.println(listingLineMsg);
if (log.isInfoEnabled()) {
log.info(listingLineMsg);
if (LOG.isInfoEnabled()) {
LOG.info(listingLineMsg);
}
}
}
Expand Down Expand Up @@ -352,9 +350,7 @@ public int run(String argv[]) throws Exception {
}
} catch (Exception e) {
// instance.run catches IOE, so something is REALLY wrong if here
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("run Error: \n cmd: %s \n exception: %s", cmd, e));
}
LOG.error("Run Error: \n cmd: %s \n Exception: %s", cmd, e);
displayError(cmd, "Fatal internal error");
}
}
Expand All @@ -364,17 +360,15 @@ public int run(String argv[]) throws Exception {
private void displayError(String cmd, String message) {
for (String line : message.split("\n")) {
error.println(cmd + ": " + line);
if (log.isDebugEnabled()) {
log.debug(cmd + ": " + line);
}
LOG.error("{}: {}", cmd, line);
if (cmd.charAt(0) != '-') {
Command instance = null;
instance = commandFactory.getInstance("-" + cmd);
String msg = "Did you mean -" + cmd + "? This command " +
"begins with a dash.";
error.println(msg);
if (instance != null) {
log.debug(msg);
LOG.error(msg);
}
}
}
Expand Down

0 comments on commit 8f32fb6

Please sign in to comment.