DataFed
DataFed copied to clipboard
Initial commit to fix log output from AuthzWorker.cpp
PR Description
Fixes bug where ofstream was going out of scope and no log output was going to file from cpp AuthzWorker. With this fix the file is being created and we are seeing the following result.
2025-02-01T05:03:57.621858Z WARN /datafed/source/repository/gridftp/globus5/authz/source/AuthzWorker.cpp:processResponse:496 { "thread_name": "authz_check-authz_worker", "message": "AuthWorker.cpp Core service did not respond within timeout." }
Tasks
- [ ] - A description of the PR has been provided, and a diagram included if it is a new feature.
- [ ] - Formatter has been run
- [ ] - CHANGELOG comment has been added
- [ ] - Labels have been assigned to the pr
- [ ] - A reviwer has been added
- [ ] - A user has been assigned to work on the pr
- [ ] - If new feature a unit test has been added
Summary by Sourcery
Bug Fixes:
- Resolve missing log output from the AuthzWorker by managing the lifetime of the output stream correctly.
Reviewer's Guide by Sourcery
This pull request fixes a bug where log output was not being written to a file due to the ofstream going out of scope. The fix ensures that the log file is created and that log messages are written to it. Additionally, the fix ensures that cerr is only added once to the logger.
Sequence diagram for the fixed logging process in AuthzWorker
sequenceDiagram
participant C as Client
participant AW as AuthzWorker
participant L as Logger
participant F as LogFile
C->>AW: checkAuthorization()
activate AW
AW->>L: addStream(cerr) if not added
Note over AW,L: Only adds cerr stream once
AW->>F: open log file
AW->>L: addStream(log_file)
Note over AW,L: Stream gets unique ID
AW->>L: log debug message
AW->>AW: perform authorization check
AW->>L: log result/errors
AW->>F: close log file
AW->>L: removeStream(stream_id)
AW-->>C: return result
deactivate AW
Class diagram showing Logger modifications
classDiagram
class Logger {
-list~StreamEntry~ m_streams
-mutex m_streams_mutex
-static uint32_t m_stream_id
-LogLevel m_log_level
-bool m_output_to_syslog
+setLevel(LogLevel)
+uint32_t addStream(ostream&)
+removeStream(uint32_t)
+setSysLog(bool)
-output(LogLevel, string, string, int, LogContext, string)
}
class StreamEntry {
+reference_wrapper~ostream~ stream
+uint32_t id
+unique_ptr~mutex~ mutex
+StreamEntry(ostream&, uint32_t)
}
Logger *-- StreamEntry
note for Logger "Changed from vector to list for better add/remove performance"
note for StreamEntry "New class to track streams with unique IDs"
File-Level Changes
| Change | Details | Files |
|---|---|---|
| The ofstream was going out of scope, preventing log output to a file. This has been fixed by ensuring the ofstream remains in scope for the duration of the log output. |
|
repository/gridftp/globus5/authz/source/AuthzWorker.cpp |
| The logger was modified to allow for the removal of streams. |
|
common/source/DynaLog.cppcommon/include/common/DynaLog.hpp |
Possibly linked issues
- #0: The PR fixes the issue by changing how the ofstream is managed, ensuring it persists and is removed from the logger when done.
Tips and commands
Interacting with Sourcery
-
Trigger a new review: Comment
@sourcery-ai reviewon the pull request. - Continue discussions: Reply directly to Sourcery's review comments.
-
Generate a GitHub issue from a review comment: Ask Sourcery to create an
issue from a review comment by replying to it. You can also reply to a
review comment with
@sourcery-ai issueto create an issue from it. -
Generate a pull request title: Write
@sourcery-aianywhere in the pull request title to generate a title at any time. You can also comment@sourcery-ai titleon the pull request to (re-)generate the title at any time. -
Generate a pull request summary: Write
@sourcery-ai summaryanywhere in the pull request body to generate a PR summary at any time exactly where you want it. You can also comment@sourcery-ai summaryon the pull request to (re-)generate the summary at any time. -
Generate reviewer's guide: Comment
@sourcery-ai guideon the pull request to (re-)generate the reviewer's guide at any time. -
Resolve all Sourcery comments: Comment
@sourcery-ai resolveon the pull request to resolve all Sourcery comments. Useful if you've already addressed all the comments and don't want to see them anymore. -
Dismiss all Sourcery reviews: Comment
@sourcery-ai dismisson the pull request to dismiss all existing Sourcery reviews. Especially useful if you want to start fresh with a new review - don't forget to comment@sourcery-ai reviewto trigger a new review! -
Generate a plan of action for an issue: Comment
@sourcery-ai planon an issue to generate a plan of action for it.
Customizing Your Experience
Access your dashboard to:
- Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others.
- Change the review language.
- Add, remove or edit custom review instructions.
- Adjust other review settings.
Getting Help
- Contact our support team for questions or feedback.
- Visit our documentation for detailed guides and information.
- Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.