forked from nus-cs2113-AY2324S2/tp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request nus-cs2113-AY2324S2#54 from IanFH/logging-file-han…
…dler Successfully set up file handler. Florizz.xml file will appear if for…
- Loading branch information
Showing
6 changed files
with
56 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1::florizz.core.Florizz::main::Fri Mar 22 18:09:06 SGT 2024::Entered isRunning while loop in Florizz.java |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package florizz.logging; | ||
|
||
import java.util.logging.Filter; | ||
import java.util.logging.Level; | ||
import java.util.logging.LogRecord; | ||
|
||
public class MyFilter implements Filter { | ||
|
||
/** | ||
* Determine what level should a handler take | ||
* Code taken from "https://www.digitalocean.com/community/tutorials/logger-in-java-logging-example" | ||
* | ||
* @param log a LogRecord | ||
* @return | ||
*/ | ||
@Override | ||
public boolean isLoggable(LogRecord log) { | ||
//don't log CONFIG logs in file | ||
if (log.getLevel() == Level.CONFIG) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package florizz.logging; | ||
|
||
import java.util.Date; | ||
import java.util.logging.Formatter; | ||
import java.util.logging.LogRecord; | ||
|
||
public class MyFormatter extends Formatter { | ||
|
||
/** | ||
* Better format logging output | ||
* Code taken from "https://www.digitalocean.com/community/tutorials/logger-in-java-logging-example" | ||
* | ||
* @param record the log record to be formatted. | ||
* @return | ||
*/ | ||
@Override | ||
public String format(LogRecord record) { | ||
return record.getThreadID()+"::"+record.getSourceClassName()+"::" | ||
+record.getSourceMethodName()+"::" | ||
+new Date(record.getMillis())+"::" | ||
+record.getMessage()+"\n"; | ||
} | ||
|
||
} |