-
Notifications
You must be signed in to change notification settings - Fork 3
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/more logging information #432
Conversation
lagoan
commented
May 10, 2024
Currently we are only logging successful events with the method ``log_preservation_event``. We want to log more information to reflect the system current work state. For now we simple change the name to that method to: ``log_preservation_success``
This WIP commit adds the different methods that will be used for logging the specific preservation events. Next we will be adding them to the logic.
This work in progress adds more information about all logging events in order to get a better idea of the behavior on PMPY. Right now the preservation event loggers are initialized on startup instead of being instantiated every time there is a preservation event. All is done in the logger reader method. We could change it so the preservation loggers are instantiated on their own access. There are 3 placeholder tests that need to be completed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was there anything in particular you wanted feedback about? It looks like you're on the right track.
Trying this in my dev environment I'm probably missing a step, because I'm getting a lot of
Error of type: Errno::ECONNRESET
Error message: Connection reset by peer
I start jupiter ./bin/setup && ./bin/dev
then in a new terminal set jupiter environment variables, ./bin/setup && bundle exec rake install
, then bundle exec pushmi_pullyu
. After than I open a new console to bundle exec rake jupiter:preserve_all_items_and_theses
in jupiter. What did I miss?
Thanks for taking a look @pgwillia . I hope to get feedback on the loggers initialization. I am piggybacking on the original logger initializer for the preservaition event logs instead of opening and closing the log files on each preservation event. The logger initializer is here: pushmi_pullyu/lib/pushmi_pullyu/logging.rb Lines 24 to 31 in ed1db2d
I kept the rest of the behaviour as it was, returning the original logger. Another approach can be to have another method to initialize the preservation event logs. This would simplify the methods but add an extra step. This is a minor issue right now, but there might be something else I do not see. |
Just add the tests for the new methods and make sure the JSON log includes its values in JSON format when needed.
@pgwillia I run it a bit differently. Sorry if I missed it, what application is giving you this error? I will add my startup method with you. |
I think it's PMPY giving the error, but could be Swift. Jupiter looks fine.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new tests look good! 👍
Did you run the new logging by Henry to see if it works for the Preservation team?
@@ -21,14 +21,17 @@ class << self | |||
|
|||
attr_writer :logger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a strong opinion on initializing the logs. I think what you've done works as well as anything else.
I was trying to find out if Ruby community has a best practice around attribute accessors vs instance variables because I see here that logger is declared this way. I couldn't find anything clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
||
it 'logs preservation event to both preservation log and application log' do | ||
# Make sure we are initialize logger with expected file destinations and not default stdout destination | ||
PushmiPullyu::Logging.initialize_loggers(events_target: "#{tmp_log_dir}/preservation_events.log", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if tagged logging could be used rather than two multiple log files/loggers? (https://api.rubyonrails.org/classes/ActiveSupport/TaggedLogging.html) I suppose it would depend on how the logs are used to troubleshoot and the content of the logs itself. I think how the logs are initialised are fine however and everything else looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a good point @ConnorSheremeta . Having different loggers was done before this work was done. I believe the idea is to have the logs handled separately so they can be parsed based on need.
I will keep in mind your suggestion if we want to simplify logging at a later date.