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

fix(log-level-config): exact duration match should return the correct level #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

abacaphiliac
Copy link
Owner

No description provided.

@abacaphiliac
Copy link
Owner Author

@holtkamp would you mind taking a look at this?

@holtkamp
Copy link
Contributor

On vacation now, so might take some time before I have time to have a good look...

@abacaphiliac
Copy link
Owner Author

@holtkamp thanks, enjoy your time off! : )

@@ -65,6 +65,11 @@ private function determineApplicableLogLevel(float $durationInSeconds) : ?string
//Acquire a common / non-associative array with all the thresholds
$durationThresholds = array_values($this->logLevelMapping);

$exactDurationMatch = array_search($durationInMilliseconds, $this->logLevelMapping);
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. this can/should be done "as early as possible" in the function?
  2. What is the chance that a duration (float) is exactly matched in a real-world situation? I think that chance is near 0... So what justifies this check? Being able to test it?

Copy link
Owner Author

Choose a reason for hiding this comment

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

  1. What is the chance that a duration (float) is exactly matched in a real-world situation? I think that chance is near 0... So what justifies this check? Being able to test it?

i agree that it is near 0. i wouldn't say that the justification is testability, rather accuracy. i tested an edge and the value i expected to get was the not the actual value.

  1. this can/should be done "as early as possible" in the function?

i think you're correct in assuming the chances are near 0. would this be more palatable at the very end of the function? before null is returned?

Copy link
Contributor

Choose a reason for hiding this comment

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

You mention two very valid points 😉. Indeed, moving the "exact match" scenario to the end seems a good place for such edge case 👍

@abacaphiliac abacaphiliac mentioned this pull request Feb 1, 2020
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