Skip to content

Commit

Permalink
Merge pull request #701 from bytedance/feat-exception
Browse files Browse the repository at this point in the history
feat exception catch
  • Loading branch information
yoloyyh authored Oct 28, 2024
2 parents eae24b0 + 21a8146 commit ff29cf8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.security.smithloader.log;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.time.Instant;
import java.util.logging.FileHandler;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
Expand All @@ -14,9 +12,8 @@ public class SmithAgentLogger {
public static Logger logger = Logger.getLogger("RASPAgent");

static {
logger.setUseParentHandlers(false);

try {
logger.setUseParentHandlers(false);
String filename = String.format("/tmp/JVMAgent.%d.log", ProcessHelper.getCurrentPID());

FileHandler handler = new FileHandler(filename, 5 * 1024 * 1024, 5, true);
Expand All @@ -25,7 +22,7 @@ public class SmithAgentLogger {
SimpleFormatter formatter = new SimpleFormatter();
handler.setFormatter(formatter);

} catch (IOException | NumberFormatException e) {
} catch (Exception e) {
e.printStackTrace();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -30,7 +29,7 @@ public static void info() {
}
}
}
} catch (IOException e) {
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import com.security.smith.common.ProcessHelper;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.time.Instant;
import java.util.logging.FileHandler;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
Expand All @@ -16,9 +14,9 @@ public class SmithLogger {


public static void loggerProberInit() {
logger.setUseParentHandlers(false);


try {
logger.setUseParentHandlers(false);
String filename = String.format("/tmp/JVMProbe.%d.log", ProcessHelper.getCurrentPID());

fileHandler = new FileHandler(filename, 5 * 1024 * 1024, 5, true);
Expand All @@ -27,7 +25,7 @@ public static void loggerProberInit() {
SimpleFormatter formatter = new SimpleFormatter();
fileHandler.setFormatter(formatter);

} catch (IOException | NumberFormatException e) {
} catch (Exception e) {
e.printStackTrace();
}
}
Expand Down

0 comments on commit ff29cf8

Please sign in to comment.