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

Add lower level logging statement #203

Conversation

Eclipse-Dominator
Copy link
Contributor

@Eclipse-Dominator Eclipse-Dominator commented Jul 28, 2023

Fixes #194

Includes some lower-level logging statements as well as moving some of the existing logging statements to other levels.

@canihasreview
Copy link

canihasreview bot commented Jul 28, 2023

Click here to submit a new iteration when this PR is ready for review.

See this repository's contribution guide for more information.

@codecov
Copy link

codecov bot commented Jul 28, 2023

Codecov Report

Merging #203 (7c506ec) into master (08fe6e3) will decrease coverage by 0.01%.
The diff coverage is 60.00%.

@@             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              
Files Changed Coverage Δ
src/main/java/seedu/address/MainApp.java 0.00% <0.00%> (ø)
.../seedu/address/logic/parser/AddressBookParser.java 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@Eclipse-Dominator Eclipse-Dominator force-pushed the add-lower-level-logging-statement branch 4 times, most recently from 769e15f to 7a4ad45 Compare July 28, 2023 01:56
@canihasreview
Copy link

canihasreview bot commented Jul 28, 2023

v1

@Eclipse-Dominator submitted v1 for review.

(📚 Archive)

Checkout this PR version locally
git fetch https:/se-edu/addressbook-level3.git refs/pr/203/1/head:BRANCHNAME

where BRANCHNAME is the name of the local branch you wish to fetch this PR to.

Copy link
Contributor

@damithc damithc left a 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 {

Copy link
Contributor

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.

Copy link
Contributor

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.

config/checkstyle/checkstyle.xml Outdated Show resolved Hide resolved
src/main/java/seedu/address/MainApp.java Outdated Show resolved Hide resolved
return new HelpCommand();

default:
logger.fine("Unknown command detected");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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.
Copy link
Contributor

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.

@Eclipse-Dominator Eclipse-Dominator force-pushed the add-lower-level-logging-statement branch 2 times, most recently from 0304e27 to 141e6cf Compare July 29, 2023 13:56
@canihasreview
Copy link

canihasreview bot commented Jul 29, 2023

v2

@Eclipse-Dominator submitted v2 for review.

(📚 Archive) (📈 Interdiff between v1 and v2) (📈 Range-Diff between v1 and v2)

Checkout this PR version locally
git fetch https:/se-edu/addressbook-level3.git refs/pr/203/2/head:BRANCHNAME

where BRANCHNAME is the name of the local branch you wish to fetch this PR to.

@canihasreview canihasreview bot requested a review from damithc July 29, 2023 13:58
Copy link
Contributor

@damithc damithc left a 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;
Copy link
Contributor

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.

Copy link
Contributor Author

@Eclipse-Dominator Eclipse-Dominator Aug 7, 2023

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.

Copy link
Contributor

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 {

Copy link
Contributor

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.

@Eclipse-Dominator Eclipse-Dominator force-pushed the add-lower-level-logging-statement branch 3 times, most recently from 0486316 to 7b5e6f4 Compare August 7, 2023 22:32
@canihasreview
Copy link

canihasreview bot commented Aug 7, 2023

v3

@Eclipse-Dominator submitted v3 for review.

(📚 Archive) (📈 Interdiff between v2 and v3) (📈 Range-Diff between v2 and v3)

Checkout this PR version locally
git fetch https:/se-edu/addressbook-level3.git refs/pr/203/3/head:BRANCHNAME

where BRANCHNAME is the name of the local branch you wish to fetch this PR to.

@canihasreview canihasreview bot requested a review from damithc August 7, 2023 22:33
@damithc
Copy link
Contributor

damithc commented Aug 9, 2023

@se-edu/tech-team-level1 for your review ...

@damithc
Copy link
Contributor

damithc commented Aug 9, 2023

@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());

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());

Copy link
Contributor Author

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.

Comment on lines 51 to 52
// Currently, lower level log messages are used sparingly, to minimize noise in the code.
logger.fine("Command word: " + commandWord + " ; Arguments: " + arguments);
Copy link

@hansstanley hansstanley Aug 9, 2023

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.

Suggested change
// 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);

Copy link
Contributor

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

Copy link

@SPWwj SPWwj left a 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);
Copy link

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.

Suggested change
logger.finer("This user input caused a ParseException: " + userInput);
logger.finer("User input caused a ParseException: " + userInput);

Or

Suggested change
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)
Copy link

Choose a reason for hiding this comment

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

Suggested change
// 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)

@damithc
Copy link
Contributor

damithc commented Aug 14, 2023

@Eclipse-Dominator reminder about this

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.
@canihasreview
Copy link

canihasreview bot commented Aug 15, 2023

v4

@Eclipse-Dominator submitted v4 for review.

(📚 Archive) (📈 Interdiff between v3 and v4) (📈 Range-Diff between v3 and v4)

Checkout this PR version locally
git fetch https:/se-edu/addressbook-level3.git refs/pr/203/4/head:BRANCHNAME

where BRANCHNAME is the name of the local branch you wish to fetch this PR to.

@@ -69,6 +78,7 @@ public Command parseCommand(String userInput) throws ParseException {
return new HelpCommand();

default:
logger.finer("ParseException: " + userInput);
Copy link
Contributor

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?

@damithc
Copy link
Contributor

damithc commented Aug 25, 2023

@Eclipse-Dominator shall we wrap this up soon?

@damithc
Copy link
Contributor

damithc commented Sep 3, 2023

Added these commits to master with minor tweaks.

@damithc damithc closed this Sep 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add lower level logging statements
5 participants