Skip to content

add log for catch (Exception) clause - #68

Closed
Andy Xu(devdiv) (andxu) wants to merge 17 commits into
masterfrom
andy_launch_attach_log
Closed

Andy Xu(devdiv) (andxu) wants to merge 17 commits into
masterfrom
andy_launch_attach_log

Conversation

@andxu

Copy link
Copy Markdown
Contributor

…exception there.

}

if (!(container instanceof VariableProxy)) {
logger.severe(String.format("VariablesRequest: Invalid variablesReference: %d", varArgs.variablesReference));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The logger usage is weird to me. I would think we provide some static method for logging, which is common way using logger.

With this, we get rid of extrace logger reference and import log level.

* This helper class provide static methods for a default instance of <code>java.util.logging.Logger</code>,providing the normal log
* methods of <code>debug</code>, <code>info</code>, <code>warning</code>, <code>error</code>, very simple code like
* <code>Log.info("Sample trace: %d", 10)</code> is able to replace <code>logger.info(String.format("Sample trace: %d", 10))</code>.
* Using a very short name to better code fitness.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Need rephrase the comment here. Just keep it simple and clear.

import java.util.logging.Logger;

/**
* This helper class provide static methods for a default instance of <code>java.util.logging.Logger</code>,providing the normal log

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

provide ==> provides

/**
* Log an ERROR message.
*
* @param ex The error object

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

error exception?

*
* @param ex The error object
* @param message The string message
* @param arguments The arguments for replacing placeholder in message.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should be placeholdes, corresponding to the arguments

Similar for other places of the comments

}

/**
* Log an WARN message.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

an ==> a

}

/**
* Log an DEBUG message.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

an ==> a

* Add a log Handler to receive logging messages.
* @param handler a logging Handler
*/
public static void addHandler(Handler handler) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there any API corresponding to remove the handler?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

added

* <code>Log.info("Sample trace: %d", 10)</code> is able to replace <code>logger.info(String.format("Sample trace: %d", 10))</code>.
* Using a very short name to better code fitness.
*/
public final class Log {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why do we need to wrap around the JDK logger? I didn't see much value added. Am I missing anything?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This PR is mainly to focus on simplifying the logging code to better code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Trace user data is also include in Log.java, Log will be the only class need to record logs and user datas.

}
} catch (IOException e) {
logger.log(Level.SEVERE, String.format("Read data from io exception: %s", e.toString()), e);
Log.error("Read data from io exception: %s", e.toString());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should Log.endSession at the end of the start method.

@andxu
Andy Xu(devdiv) (andxu) deleted the andy_launch_attach_log branch November 22, 2017 06:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants