Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Runtime.logRuntimeException() API
- Loading branch information
Gene Gleyzer
committed
May 9, 2024
1 parent
3d0bc68
commit 7bc3668
Showing
8 changed files
with
45 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -132,6 +132,18 @@ public void setDebuggerActive(boolean fActive) | |
m_fDebugger = fActive; | ||
} | ||
|
||
/** | ||
* Log a runtime exception. Eventually, this will go to a log file... | ||
* | ||
* @return an error tag the logged exception | ||
*/ | ||
public static String logRuntimeException(String sErr) | ||
{ | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
lagergren
Contributor
|
||
String sTag = "RTError: " + System.currentTimeMillis(); | ||
System.err.println("*** " + sTag + '\n' + sErr); | ||
return sTag; | ||
} | ||
|
||
|
||
// ----- constants and fields ------------------------------------------------------------------ | ||
|
||
|
This file contains 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 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 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 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 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 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 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
I think it would be better if we started on a "standardised" way to do logging. If we could use a simple slf4j API for all our logging needs instead of calling System.err, it would be simple to extend, add multiple log sinks, turn into structured logging, or add something that logs data that we save and mine in big query from all our customers, or whatever we want to do.
The Gradle logger is already an extension of the slf4j api, and there is a very simple implementation of it on mavenCentral and everywhere else that just prints to stdout or stderr, but still uses a logger with different log levels, compatible with the superclass of the Gradle logger.
https://www.slf4j.org/manual.html
Using the api (compile classpath level) and the slf4j-simple artifact as the implementation will give you a bare bones console printing abstracted logger that can be replaced with better implementations the more functionality we need, keeping the log calls unchanged, regardless of implementation.
https://mvnrepository.com/artifact/org.slf4j/slf4j-api
https://mvnrepository.com/artifact/org.slf4j/slf4j-simple
Ready made artifacts above. Luckily we speak Maven. Just slam them into libs.versions.toml, add some dependencies to the runtime classes and replace-in-files your System.err.println to logger.info or whatever it is ...