-
Notifications
You must be signed in to change notification settings - Fork 38
Starts logging #34
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
Open
cptwonton
wants to merge
4
commits into
TestingResearchIllinois:master
Choose a base branch
from
cptwonton:STARTS-LOGGING
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Starts logging #34
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,94 @@ | ||
|
|
||
| # Logging | ||
|
|
||
| ## Intro | ||
|
|
||
| Logging in STARTS is a customized (read: simpler) version of [java.util.logging (JUL)](https://docs.oracle.com/javase/8/docs/api/java/util/logging/package-summary.html). | ||
|
|
||
| The code for logging is located in starts-core/src/main/java/edu/illinois/starts/util/Logger.java | ||
|
|
||
|
|
||
| For any piece of starts that you'd like to add logging to, begin by adding two import statements at the top: | ||
|
|
||
| - ``import edu.illinois.starts.util.Logger;`` | ||
| - ``import java.util.logging.Level;`` | ||
|
|
||
| _note: you may need to make minor changes to the positioning of these two import statements to ensure checkstyle does not break. Place ``edu.illinois.starts.util.Logger`` directly underneath the other imports with the same package name, and do the same with ``java.util.logging.Level``. Additionally, ensure you have a newline separating different package names_ | ||
owolabileg marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| Next, instantiate your Logger as a class variable: | ||
| - ``protected static final Logger logger = Logger.getGlobal();`` | ||
|
|
||
| ## Levels | ||
| There are 7 logging levels (excluding OFF and ALL), just like JUL: | ||
| - SEVERE (highest value) | ||
| - WARNING | ||
| - __INFO (default)__ | ||
| - CONFIG | ||
| - FINE | ||
| - FINER | ||
| - FINEST (lowest value) | ||
|
|
||
| To set the logging level of your log, use the | ||
|
|
||
| ``setLoggingLevel(Level level)`` | ||
|
|
||
| method. | ||
| i.e., | ||
|
|
||
| ``logger.setLoggingLevel(Level.CONFIG);`` | ||
|
|
||
| To check the logging level, use the ``getLoggingLevel()`` method, which will return an object of type [Level](https://docs.oracle.com/javase/8/docs/api/java/util/logging/Level.html). | ||
| i.e., | ||
|
|
||
| ``Level currentLevel = logger.getLoggingLevel();`` | ||
|
|
||
| ## Writing messages | ||
| There are two methods you can use to log that differ only in the number of arguments you pass in. | ||
|
|
||
| ###### ``public void log(Level lev, String msg, Throwable thr)`` | ||
| should be used when you want to have a custom message AND an exception message | ||
|
|
||
|
|
||
| ###### ``public void log(Level lev, String msg)`` | ||
| should be used when you only want to have a custom message | ||
|
|
||
| i.e., | ||
|
|
||
| ``logger.log(Level.SEVERE, "houston we have a problem");`` | ||
|
|
||
| In both cases above, the provided message will only be logged if the specified logging Level is equal to or higher in severity than the Level the logger is set to. | ||
| For example, if ``logger.setLoggingLevel(Level.SEVERE);``, then only ``logger.log()`` messages with Level.SEVERE will be spit out. | ||
| Similarly, if ``logger.setLoggingLevel(Level.CONFIG);``, then ``logger.log()`` with Level.INFO will be output, but not Level.FINER. | ||
|
|
||
| ## Where will messages be output? | ||
| Standard Output (System.out) | ||
|
|
||
| ## Artifact storage | ||
| The logging granularities serve a dual purpose - both to control which log messages in code are sent to standard output, AND to control which artifacts are stored between runs. | ||
|
|
||
| The default __Level.INFO__ will store: | ||
| - _dependency file/checksum (.starts/deps.zlc)_ | ||
|
|
||
| __Level.FINER__ will store: | ||
| - _dependency file/checksum (.starts/deps.zlc)_ | ||
| - _list of all tests_ | ||
| - _list of impacted tests_ | ||
|
|
||
| __Level.FINEST__ will store: | ||
| - _dependency file/checksum (.starts/deps.zlc)_ | ||
| - _list of all tests_ | ||
| - _list of impacted tests_ | ||
| - _list of non-impacted tests_ | ||
| - _list of dependencies computed by jdeps_ | ||
| - _classpath that STARTS used_ | ||
| - _yasgl graph that STARTS constructed_ | ||
| - _set of changed types_ | ||
|
|
||
| To set the log level at runtime, call starts like this: | ||
|
|
||
| ``mvn starts:starts -DstartsLogging=<Level>`` | ||
|
|
||
| i.e., | ||
|
|
||
| ``mvn starts:starts -DstartsLogging=FINEST`` | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.