Skip to content

[VUFIND-1793] Logger improvements - #5609

Open
meganschanz wants to merge 4 commits into
vufind-org:devfrom
MSU-Libraries:logger-improvements
Open

[VUFIND-1793] Logger improvements#5609
meganschanz wants to merge 4 commits into
vufind-org:devfrom
MSU-Libraries:logger-improvements

Conversation

@meganschanz

Copy link
Copy Markdown
Contributor

This implements the changes discussed in VUFIND-1793 which add some quality of life improvements to logging. I updated the log calls that were added in #4678 as a sample of usage going forward.

I also have a draft ready of updates to include on https://vufind.org/wiki/development:architecture:logging once this is merged.

@meganschanz

Copy link
Copy Markdown
Contributor Author

No urgency at all to review this (it's not blocking any other work). I just had some free time this afternoon and thought I'd get this off my to-do list.

@demiankatz demiankatz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, @meganschanz, this looks good to me -- see below for a few nitpicks and suggested simplifications (I just can't resist compacting or null coalescing when I see an opportunity).

Comment thread module/VuFind/src/VuFind/Log/Logger.php Outdated
*/
protected function fillInMissingDetails(array $context = []): array
{
if (!array_key_exists('details', $context) || !is_array($context['details'])) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This might be a little simpler:

Suggested change
if (!array_key_exists('details', $context) || !is_array($context['details'])) {
if (!is_array($context['details'] ?? null)) {

Comment thread module/VuFind/src/VuFind/Log/Logger.php Outdated

foreach ($levels as $level) {
// This level has data, no need to look further
if (isset($details[$level]) && $details[$level] !== '') {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Slightly more concise:

Suggested change
if (isset($details[$level]) && $details[$level] !== '') {
if (($details[$level] ?? '') !== '') {

Comment thread module/VuFind/src/VuFind/Log/Logger.php Outdated
}

// Try prior index (Backfill)
if (isset($details[$level - 1]) && $details[$level - 1] !== '') {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
if (isset($details[$level - 1]) && $details[$level - 1] !== '') {
if (($details[$level - 1] ?? '') !== '') {

Comment thread module/VuFind/src/VuFind/Log/Logger.php Outdated
}

// Try next index (Frontfill)
if (isset($details[$level + 1]) && $details[$level + 1] !== '') {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
if (isset($details[$level + 1]) && $details[$level + 1] !== '') {
if (($details[$level + 1] ?? '') !== '') {

Comment thread module/VuFind/src/VuFind/Log/Logger.php Outdated
Comment on lines +356 to +358
[
'details' => $details,
]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

More concise:

Suggested change
[
'details' => $details,
]
compact('details')

*
* @param \Exception $exception Exception to log
* @param \Exception $exception Exception to log
* @param \Laminas\Stdlib\Parameters $server Optional server metadata

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This appears to support array format and null as well; might as well document that.

Suggested change
* @param \Laminas\Stdlib\Parameters $server Optional server metadata
* @param \Laminas\Stdlib\Parameters|array|null $server Optional server metadata

@meganschanz

Copy link
Copy Markdown
Contributor Author

The suggested changes have been applied.

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