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

Add streamline Logger #1500

Merged
merged 4 commits into from
Aug 26, 2024
Merged

Add streamline Logger #1500

merged 4 commits into from
Aug 26, 2024

Conversation

DavidLegg
Copy link
Contributor

@DavidLegg DavidLegg commented Jul 10, 2024

  • Tickets addressed: N/A
  • Review: By commit
  • Merge strategy: Merge (no squash)

Description

Adds a Logger class to the streamline framework, which uses topics to emit log messages directly as events. Also builds such a Logger when the Registrar is initialized, and reconfigures errors to go to that logger when the error behavior is set to LOG. Before this, errors were collected awkwardly into a discrete string resource.

Verification

Since the logger is connected to the Registrar's error behavior, this was tested using the streamline-demo example model. By adding "CauseError" activities to the plan, we can trip the resource error handling machinery, and verify that appropriate error messages appear in the Simulation Events tab.

image

Documentation

None yet - #1494 should probably be updated to tell users how to use the logger in their model/activities.

This does remove the errors resource, but it leaves the numberOfErrors resource intact, which we should note for any users who may have depended on errors.

Future work

None planned

Copy link
Collaborator

@mattdailis mattdailis left a comment

Choose a reason for hiding this comment

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

Copy link
Collaborator

@mattdailis mattdailis 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 making this backwards compatible! Looks good to me

EDIT: Resolving conversation below so it doesn't block merge, but copying up here for visibility:

In the event that users have written constraints that depend on the previous resource definition, it may be worth calling out in the release notes [that the errors resources has been replaced with a numberOfErrors resource]. Not a reason not to make this change, but worth communicating explicitly.

@DavidLegg
Copy link
Contributor Author

One slight correction to that note on the errors and numberOfErrors resources - We actually had numberOfErrors already, just derived in a different way. This PR does remove errors itself, though, so I agree we should put that in the release notes just in case.

David Legg and others added 4 commits August 26, 2024 11:15
Adds a Logger class to the streamline framework, which uses topics to emit log messages directly as events.
Also builds such a Logger when the Registrar is initialized, and reconfigures errors to go to that logger when the error behavior is set to LOG.
Before this, errors were collected awkwardly into a discrete string resource.
Move the primary Logger instance to a separate class, out of Registrar.
This makes more sense logically, as Logging only incidentally depends on the Registrar, in the sense that creating the Registrar is a natural place to initialize all of the singletons.
It also makes the logger easier to find (I hope).
Per @mattdailis' suggestion, since serialized events are tagged with the time they're emitted already, there's no need to include that information in the log message itself.
Further, removing that dependency on the plan start time makes this PR fully backwards-compatible.
@dandelany dandelany force-pushed the refactor/streamline-logging branch from efecb61 to f4ddb29 Compare August 26, 2024 18:15
@dandelany dandelany merged commit f57c9a7 into develop Aug 26, 2024
6 checks passed
@dandelany dandelany deleted the refactor/streamline-logging branch August 26, 2024 18:47
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.

4 participants