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

Refactor: New Logging framework #52

Merged
merged 43 commits into from
Nov 26, 2022
Merged

Refactor: New Logging framework #52

merged 43 commits into from
Nov 26, 2022

Conversation

sillydan1
Copy link
Collaborator

New Logging Framework

This PR adds a revamp of the log-tab panel(s). Providing a much more extendable and unified way for notifying the user with information, warnings and errors.

Screen.Recording.2022-11-12.at.14.33.04.mov

How to use

Using the logging framework is easy, thread-safe and reactive!

Anatomy of a log entry

UUID id,                // autogenerated uuid
String service,         // service that produced the service
String message,         // information about what happened
LogLevel level          // Info/Warn/Error level

Add Entries

The basic usage - simply add new logs:

Log.addInfo("Some information")
Log.addWarning("Some warning");
Log.addError("Some error");

Origin Service

If the log originates from somewhere that is not an internal place (i.e. jecdar, uppaal, codeanalysis or some custom program), you can specify what service generated the log:

var myService = "NotHuppaal";
Log.addInfo(myService, "Some information")
Log.addWarning(myService, "Some warning");
Log.addError(myService, "Some error");

Links

You can add inline links to your log message, markdown style:

Log.addWarning("Something is wrong at location [L23](component:MyComponent/L23). Please check it out");

A link can link to many types of things:

// location regex:      [text](location:ComponentName/LocationId)
// edge regex:          [text](edge:ComponentName/EdgeId)
// subcomponent regex:  [text](subcomponent:ComponentName/SubcomponentId)
// jork regex:          [text](jork:ComponentName/JorkId)
// tag regex:           [text](tag:ComponentName/TagId)
// query regex:         [text](query:QueryId)
// component regex:     [text](component:ComponentName)
// file:                [text](generic:filename) (open OS default app)

On Log Entry Events

You can also add event listeners for when new logs are added:

private void subscribeOnLogAdded() {
    Log.addOnLogAddedListener(this::onLogAdded);
}

private void onLogAdded(Log log) {
    // Your code here...
}

Note that the events are being called on the main javafx thread - so you don't need to perform any Platform.runLater operations in your handlers.

Backwards Compatibility

You may notice that this PR doesn't remove the old tabs. This is on purpose. Links to locations doesn't actually work at the moment, since classes in the dk.cs.aau.huppaal.abstractions.* (everything that is a Nearable implementation) doesn't know who their parent component is, so they can't actually create any (working) clickable links. Because of this, I haven't implemented all syntactic elements in the LogLinkQuantifier enumeration.

I have integrated all static functions from CodeAnalysis to also use the new logging framework. I haven't deleted the old code though.

Log should support regex-powered nearables now.

Also, all usages of CodeAnalysis should be ported to use the new Log framework
…links

This is very much based on one of the demos
This makes it flow a bit better with the rest of the UI
There were an issue when the very first element added to the logArea was done from a separate thread whilst autoscroll was enabled. This has been sidestepped now.
@sillydan1 sillydan1 requested review from Nielswps and yrke and removed request for Nielswps November 12, 2022 14:07
@sillydan1 sillydan1 removed the request for review from yrke November 13, 2022 07:37
@sillydan1 sillydan1 mentioned this pull request Nov 13, 2022
6 tasks
@sillydan1
Copy link
Collaborator Author

Update: current implementations of Nearable will be linked correctly (the old tabs are still present, but I am fairly sure they could be removed pretty soon):

Screen.Recording.2022-11-15.at.22.16.53.mov

Copy link
Contributor

@Nielswps Nielswps left a comment

Choose a reason for hiding this comment

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

Really cool feature and a very nice graphical representation. Good job 👍

The comments are primarily about improvements to the readability of the code.

src/main/java/dk/cs/aau/huppaal/abstractions/Edge.java Outdated Show resolved Hide resolved
src/main/java/dk/cs/aau/huppaal/abstractions/Jork.java Outdated Show resolved Hide resolved
src/main/java/dk/cs/aau/huppaal/abstractions/Location.java Outdated Show resolved Hide resolved
src/main/java/dk/cs/aau/huppaal/logging/Log.java Outdated Show resolved Hide resolved
@sillydan1 sillydan1 requested a review from Nielswps November 26, 2022 10:49
Copy link
Contributor

@Nielswps Nielswps left a comment

Choose a reason for hiding this comment

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

Thanks for implementing the suggestions and explaining some of the features. The PR looks ready to merch 😁 👍

@sillydan1 sillydan1 merged commit 43d4efe into master Nov 26, 2022
@sillydan1 sillydan1 deleted the refactor/logging branch November 26, 2022 19:07
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.

2 participants