Skip to content

Commit df51ce7

Browse files
cptwontoncptwonton
authored andcommitted
Create STARTS-LOGGING.md
adds logging documentation to STARTS, incorporating the paper's details on artifact storage
1 parent 0c7c83f commit df51ce7

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ checksums of files in the latest version, while the command in (4)
6767
behavior. For example, to update the checksums while checking the
6868
diff, run `mvn starts:diff -DupdateDiffChecksums=true`.
6969

70+
[Logging and Artifact storage Docs](./STARTS-LOGGING.md)
71+
7072
## Papers on STARTS
7173

7274
Below is a list of research papers that describe some aspects of

STARTS-LOGGING.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
2+
# Logging
3+
4+
## Intro
5+
6+
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).
7+
8+
The code for logging is located in starts-core/src/main/java/edu/illinois/starts/util/Logger.java
9+
10+
11+
12+
For any piece of starts that you'd like to add logging to, begin by adding two import statements at the top:
13+
- ``import edu.illinois.starts.util.Logger;``
14+
- ``import java.util.logging.Level;``
15+
_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_
16+
17+
Next, instantiate your Logger as a class variable:
18+
- ``protected static final Logger logger = Logger.getGlobal();``
19+
20+
## Levels
21+
There are 7 logging levels (excluding OFF and ALL), just like JUL:
22+
- SEVERE (highest value)
23+
- WARNING
24+
- __INFO (default)__
25+
- CONFIG
26+
- FINE
27+
- FINER
28+
- FINEST (lowest value)
29+
30+
To set the logging level of your log, use the ``setLoggingLevel(Level level)`` method.
31+
i.e.
32+
``logger.setLoggingLevel(Level.CONFIG);``
33+
34+
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).
35+
i.e.
36+
``Level currentLevel = logger.getLoggingLevel();``
37+
38+
## Writing messages
39+
There are two methods you can use to log that differ only in the number of arguments you pass in.
40+
41+
###### ``public void log(Level lev, String msg, Throwable thr)``
42+
should be used when you want to have a custom message AND an exception message
43+
44+
45+
###### ``public void log(Level lev, String msg)``
46+
should be used when you only want to have a custom message
47+
48+
i.e. ``logger.log(Level.SEVERE, "houston we have a problem");``
49+
50+
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.
51+
For example, if ``logger.setLoggingLevel(Level.SEVERE);``, then only ``logger.log()`` messages with Level.SEVERE will be spit out.
52+
Similarly, if ``logger.setLoggingLevel(Level.CONFIG);``, then ``logger.log()`` with Level.INFO will be output, but not Level.FINER.
53+
54+
## Where will messages be output?
55+
Standard Output (System.out)
56+
57+
## Artifact Storage
58+
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.
59+
60+
The default Level.INFO will store:
61+
- checksum
62+
- dependency file (.starts/deps.zlc)
63+
64+
Level.FINER will store:
65+
- dependency file (.starts/deps.zlc)
66+
- list of all tests
67+
- list of impacted tests
68+
69+
Level.FINEST will store:
70+
- list of all tests
71+
- list of impacted tests
72+
- list of non-impacted tests
73+
- list of dependencies computed by jdeps
74+
- classpath that STARTS used
75+
- yasgl graph that STARTS constructed
76+
- set of changed types
77+
78+
To set the log level at runtime, call starts like this:
79+
80+
``mvn starts:starts -DStartsLogging=<Level>``
81+
82+
i.e. ``mvn starts:starts -DStartsLogging=FINEST``

0 commit comments

Comments
 (0)