-
Notifications
You must be signed in to change notification settings - Fork 430
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
Add lower level logging statement #203
Add lower level logging statement #203
Conversation
Click here to submit a new iteration when this PR is ready for review. See this repository's contribution guide for more information. |
Codecov Report
@@ Coverage Diff @@
## master #203 +/- ##
============================================
- Coverage 75.26% 75.26% -0.01%
Complexity 419 419
============================================
Files 71 71
Lines 1334 1338 +4
Branches 126 126
============================================
+ Hits 1004 1007 +3
- Misses 300 301 +1
Partials 30 30
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
769e15f
to
7a4ad45
Compare
v1@Eclipse-Dominator submitted v1 for review.
Checkout this PR version locallygit fetch https://github.com/se-edu/addressbook-level3.git refs/pr/203/1/head:BRANCHNAME where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions added. Mainly, to reduce the blast radius of this code update. As it is a low-gain change, let's keep the cost low.
@@ -53,14 +53,13 @@ public void init() throws Exception { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested commit message:
In the MainApp class, let's move the call to the initLogging method
closer to the start of the execution start point, to minimize the
possibility of log statements being executed before the desired log
level is set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed this earlier. Adjust the commit message subject to match the body.
src/main/java/seedu/address/logic/parser/AddressBookParser.java
Outdated
Show resolved
Hide resolved
src/main/java/seedu/address/logic/parser/AddressBookParser.java
Outdated
Show resolved
Hide resolved
return new HelpCommand(); | ||
|
||
default: | ||
logger.fine("Unknown command detected"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger.fine("Unknown command detected"); | |
logger.finer("This user input caused a ParseException: " + userInput); |
@@ -74,6 +74,8 @@ public void init() throws Exception { | |||
* or an empty address book will be used instead if errors occur when reading {@code storage}'s address book. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested commit message:
Add examples of lower-level log messages
Let's add a few examples of lower-level log messages, to illustrate to
developers how they can be used in this codebase.
0304e27
to
141e6cf
Compare
v2@Eclipse-Dominator submitted v2 for review.
(📚 Archive) (📈 Interdiff between v1 and v2) (📈 Range-Diff between v1 and v2) Checkout this PR version locallygit fetch https://github.com/se-edu/addressbook-level3.git refs/pr/203/2/head:BRANCHNAME where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like my review was stuck in pending state until now.
@@ -142,7 +143,7 @@ protected Config initConfig(Path configFilePath) { | |||
*/ | |||
protected UserPrefs initPrefs(UserPrefsStorage storage) { | |||
Path prefsFilePath = storage.getUserPrefsFilePath(); | |||
logger.info("Using preference file : " + prefsFilePath); | |||
logger.fine("Using preference file : " + prefsFilePath); | |||
|
|||
UserPrefs initializedPrefs; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use fine/finer for info that users shouldn't see but useful for developers. If the log messages in this class are useful for users, use info level- otherwise OK to use the fine level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My opinion on this is that users should only see logs when a new file is created or some error occurred while trying to load the file. When the file is loaded correctly from the path, I feel that the logs here aren't actually useful for the users but more for developers since it's expected to be loaded correctly for the user which was why I opt to use fine for logs that say "Using xxx file: ".
The argument to use info logs might be if the user wants to edit/modify the related files manually so it might be useful to show file path location with info but based on the ug, so there isn't really a need to display the file locations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a fair point. But the UG mentions the data file only.
Also, the log is not for errors/warnings only -- if we wanted that, we should have set the default log level to WARN or ERROR. At INFO level, it should show important activities that are happening.
@@ -53,14 +53,13 @@ public void init() throws Exception { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed this earlier. Adjust the commit message subject to match the body.
src/main/java/seedu/address/logic/parser/AddressBookParser.java
Outdated
Show resolved
Hide resolved
src/main/java/seedu/address/logic/parser/AddressBookParser.java
Outdated
Show resolved
Hide resolved
0486316
to
7b5e6f4
Compare
v3@Eclipse-Dominator submitted v3 for review.
(📚 Archive) (📈 Interdiff between v2 and v3) (📈 Range-Diff between v2 and v3) Checkout this PR version locallygit fetch https://github.com/se-edu/addressbook-level3.git refs/pr/203/3/head:BRANCHNAME where |
@se-edu/tech-team-level1 for your review ... |
@Eclipse-Dominator pls update the PR description to match the current state of the changes done. |
@@ -74,6 +74,8 @@ public void init() throws Exception { | |||
* or an empty address book will be used instead if errors occur when reading {@code storage}'s address book. | |||
*/ | |||
private Model initModelManager(Storage storage, ReadOnlyUserPrefs userPrefs) { | |||
logger.info("Using data file : " + storage.getAddressBookFilePath()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There looks like there is an extra space here before the colon
Current code:
logger.info("Using data file : " + storage.getAddressBookFilePath());
Proposed Change:
logger.info("Using data file: " + storage.getAddressBookFilePath());
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi sorry for the late update, the formatting is like to follow the other similar logging statements found in MainApp
where a space is included before the colon.
// Currently, lower level log messages are used sparingly, to minimize noise in the code. | ||
logger.fine("Command word: " + commandWord + " ; Arguments: " + arguments); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps this comment can be rephrased so it doesn't describe a point in time, as markers like "currently" make code comments harder to maintain.
Instead, it could describe the desired usage, for e.g. "Lower level log messages should be used sparingly to minimise noise in the code."
Also there's a space before the inline semicolon, not sure if that's intended.
// Currently, lower level log messages are used sparingly, to minimize noise in the code. | |
logger.fine("Command word: " + commandWord + " ; Arguments: " + arguments); | |
// Lower level log messages should be used sparingly to minimize noise in the code. | |
logger.fine("Command word: " + commandWord + "; Arguments: " + arguments); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead, it could describe the desired usage, for e.g. "Lower level log messages should be used sparingly to minimise noise in the code."
Good point @hansstanley
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just some minor suggestion to make the comments more succinct.
@@ -69,6 +78,7 @@ public Command parseCommand(String userInput) throws ParseException { | |||
return new HelpCommand(); | |||
|
|||
default: | |||
logger.finer("This user input caused a ParseException: " + userInput); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
is redundant, as you have already specified the userInput
.
logger.finer("This user input caused a ParseException: " + userInput); | |
logger.finer("User input caused a ParseException: " + userInput); |
Or
logger.finer("This user input caused a ParseException: " + userInput); | |
logger.finer("ParseException: " + userInput); |
@@ -42,6 +45,12 @@ public Command parseCommand(String userInput) throws ParseException { | |||
|
|||
final String commandWord = matcher.group("commandWord"); | |||
final String arguments = matcher.group("arguments"); | |||
|
|||
// Note to developers: Change the log level in config.json to enable lower level (i.e., FINE and lower) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Note to developers: Change the log level in config.json to enable lower level (i.e., FINE and lower) | |
// Note to developers: Change the log level in config.json to enable lower level (i.e., FINE, FINER and lower) |
@Eclipse-Dominator reminder about this |
7b5e6f4
to
2d172b9
Compare
Let's add a few examples of lower-level log messages, to illustrate to developers how they can be used in this codebase.
In the MainApp class, let's move the call to the initLogging method closer to the start of the execution start point, to minimize the possibility of log statements being executed before the desired log level is set.
2d172b9
to
7c506ec
Compare
v4@Eclipse-Dominator submitted v4 for review.
(📚 Archive) (📈 Interdiff between v3 and v4) (📈 Range-Diff between v3 and v4) Checkout this PR version locallygit fetch https://github.com/se-edu/addressbook-level3.git refs/pr/203/4/head:BRANCHNAME where |
@@ -69,6 +78,7 @@ public Command parseCommand(String userInput) throws ParseException { | |||
return new HelpCommand(); | |||
|
|||
default: | |||
logger.finer("ParseException: " + userInput); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suppose the user input blah
caused a ParseException. Compare the following two log messages:
ParseException: blah
This user input cased a ParseException: blah
I think the latter is more self-explanatory. The former can even mislead the reader to think blah
is the ParseException.
What do you think?
@Eclipse-Dominator shall we wrap this up soon? |
Added these commits to master with minor tweaks. |
Fixes #194
Includes some lower-level logging statements as well as moving some of the existing logging statements to other levels.