Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed logging issue #145 #149

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/br/ufpe/cin/app/JFSTMerge.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
public class JFSTMerge {

//log of activities
private final Logger LOGGER = LoggerFactory.make();
private static final Logger LOGGER = LoggerFactory.make();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leonardoAnjos16 só isso resolveu a bronca toda?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Foi! Isso e a edição em LoggerFactory!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leonardoAnjos16 beleza, vais adicionar mais algum commit, ou posso integrar?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pode integrar!


public static final double RENAMING_SIMILARITY_THRESHOLD = 0.7; //a typical value of 0.7 (up to 1.0) is used, increase it for a more accurate comparison, or decrease for a more relaxed one.

Expand Down
33 changes: 16 additions & 17 deletions src/main/java/br/ufpe/cin/logging/LoggerFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,28 @@ public static Logger make() {

try {
if (!Files.exists(LOG_FILE_PATH)) {

if (!Files.exists(LOG_FILE_PATH.getParent()))
Files.createDirectory(LOG_FILE_PATH.getParent());
} else {
manageLogBuffer();
}

// creating FileHandler to record the logs
FileHandler fileHandler = new FileHandler(LOG_FILE_PATH.toString(), true);

// setting formatter to the handler
fileHandler.setFormatter(new SimpleFormatter());
fileHandler.setEncoding("UTF-16");
// creating FileHandler to record the logs
FileHandler fileHandler = new FileHandler(LOG_FILE_PATH.toString(), true);
// setting formatter to the handler
fileHandler.setFormatter(new SimpleFormatter());
fileHandler.setEncoding("UTF-16");

// setting Level to ALL
fileHandler.setLevel(Level.ALL);
logger.setLevel(Level.ALL);
// setting Level to ALL
fileHandler.setLevel(Level.ALL);
logger.setLevel(Level.ALL);

// disable console output
logger.setUseParentHandlers(false);
// disable console output
logger.setUseParentHandlers(false);

// assigning handler to logger
logger.addHandler(fileHandler);
} else {
manageLogBuffer();
}
// assigning handler to logger
logger.addHandler(fileHandler);
} catch (IOException e) {
logger.log(Level.SEVERE, "Error occur during logging's creation.", e);
}
Expand Down
9 changes: 6 additions & 3 deletions src/test/java/br/ufpe/cin/unit/LoggerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,24 @@ public void write(int b) {}

@Test
public void testLogger_givenTheresOneMergerObject_whenTwoConsecutiveMergesOccur_shouldProduceOnlyOneLogFile() throws IOException {
int numberOfLogFilesBeforeExecution = numberOfLogFiles();

JFSTMerge merger = new JFSTMerge();

merge(merger, "deletioninleft");
merge(merger, "deletioninright");

assertEquals(1, numberOfLogFiles());
assertEquals(numberOfLogFilesBeforeExecution, numberOfLogFiles());
}

@Test
public void testLogger_whenTwoConsecutiveMergesOccur_shouldProduceOnlyOneLogFile() throws IOException {
int numberOfLogFilesBeforeExecution = numberOfLogFiles();

merge(new JFSTMerge(), "deletioninleft");
merge(new JFSTMerge(), "deletioninright");

assertEquals(1, numberOfLogFiles());

assertEquals(numberOfLogFilesBeforeExecution, numberOfLogFiles());
}

private int numberOfLogFiles() throws IOException {
Expand Down