Skip to content

debugbar logging requests using microtime#5643

Closed
maniaba wants to merge 28 commits intocodeigniter4:developfrom
maniaba:develop
Closed

debugbar logging requests using microtime#5643
maniaba wants to merge 28 commits intocodeigniter4:developfrom
maniaba:develop

Conversation

@maniaba
Copy link
Copy Markdown
Contributor

@maniaba maniaba commented Feb 2, 2022

Feature request from the forum: https://forum.codeigniter.com/thread-81113.html

Each pull request should address a single issue and have a meaningful title.

Description
Explain what you have changed, and why.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@kenjis
Copy link
Copy Markdown
Member

kenjis commented Feb 2, 2022

@maniaba
Copy link
Copy Markdown
Contributor Author

maniaba commented Feb 2, 2022

@kenjis
Copy link
Copy Markdown
Member

kenjis commented Feb 2, 2022

Your sign is unverified.

The email in this signature doesn’t match the committer email.

@kenjis kenjis added the enhancement PRs that improve existing functionalities label Feb 2, 2022
* @param int $limit Max history files
*/
public function setFiles(int $current, int $limit = 20)
public function setFiles(float $current, int $limit = 20)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need to break the signature here? I think we could just pass around the microtime as an int and then do number_format right before outputting.

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 is BC break.

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.

Given the limitations, I think it is acceptable to change the signature albeit a breaking change. Let's wait for other's opinions. @kenjis @MGatner ?

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.

I don't mind (necessary) BC in minor version up if it is documented.
See https://forum.codeigniter.com/thread-80892-post-392846.html#pid392846

By the way, is float enough?
It seems only 4 digits like 1643882644.5667 in my PHP.

Copy link
Copy Markdown
Contributor Author

@maniaba maniaba Feb 3, 2022

Choose a reason for hiding this comment

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

Maybe change this to a string, and make the file name look like "debugbar_{microtime} _ {session_value} .json" or add session_value to the contents of the file?
Then we will solve the request "when multiple developers work on different modules I suggest the option that developers can filter requests by session so that everyone can see it's own requests made by their browser."
I suggest adding a checkbox to the history tab, which would filter sessions by the browser.

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.

That is a good refinement to the Debug Toolbar, but let us limit this PR to adding the microtime only. We can add the session and filtering in another PR.

Copy link
Copy Markdown
Member

@kenjis kenjis Feb 5, 2022

Choose a reason for hiding this comment

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

I think type string is better. It is actually (a part of) filename, not time.

Comment thread system/Debug/Toolbar.php Outdated
Comment thread system/Debug/Toolbar.php Outdated
Comment thread system/Debug/Toolbar/Collectors/History.php Outdated
* @param int $limit Max history files
*/
public function setFiles(int $current, int $limit = 20)
public function setFiles(float $current, int $limit = 20)
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 is BC break.

Comment thread system/Debug/Toolbar/Collectors/History.php Outdated
Comment thread tests/system/Debug/Toolbar/Collectors/HistoryTest.php Outdated
@paulbalandan paulbalandan added the breaking change Pull requests that may break existing functionalities label Feb 3, 2022
@maniaba maniaba requested a review from paulbalandan February 3, 2022 08:33
Comment thread tests/system/Debug/Toolbar/Collectors/HistoryTest.php Outdated
Comment thread tests/system/Debug/Toolbar/Collectors/HistoryTest.php Outdated
Comment thread tests/system/Debug/Toolbar/Collectors/HistoryTest.php Outdated
Comment thread tests/system/Debug/Toolbar/Collectors/HistoryTest.php Outdated
Comment thread tests/system/Debug/Toolbar/Collectors/HistoryTest.php Outdated
Comment thread tests/system/Debug/Toolbar/Collectors/HistoryTest.php Outdated
Comment thread tests/system/Debug/Toolbar/Collectors/HistoryTest.php Outdated
@paulbalandan paulbalandan removed the breaking change Pull requests that may break existing functionalities label Feb 3, 2022
@paulbalandan
Copy link
Copy Markdown
Member

@maniaba Please add to the user guide changelog (1) debug toolbar is now using microtime instead of time, and (2) there is a possible BC break for those users extending the History Collector and they should probably update setFiles() method

@kenjis
Copy link
Copy Markdown
Member

kenjis commented Feb 5, 2022

This is not (int):

$history->setFiles(
(int) Services::request()->getGet('debugbar_time'),
$this->config->maxHistory
);

@kenjis
Copy link
Copy Markdown
Member

kenjis commented Feb 12, 2022

@kenjis kenjis added the stale Pull requests with conflicts label Feb 21, 2022
@kenjis kenjis added breaking change Pull requests that may break existing functionalities and removed stale Pull requests with conflicts labels Feb 24, 2022
@kenjis
Copy link
Copy Markdown
Member

kenjis commented Feb 24, 2022

@maniaba
It seems you used git merge. Is it difficult to use git rebase?
See https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/workflow.md#pushing-your-branch

Comment thread system/Debug/Toolbar.php Outdated
Comment thread system/Debug/Toolbar.php Outdated
Comment thread system/Debug/Toolbar/Collectors/History.php Outdated
Copy link
Copy Markdown
Member

@kenjis kenjis left a comment

Choose a reason for hiding this comment

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

The current implementation always shows 00 at the end of Datetime.
Microtime has 6 digits, so it is better to show 6 digits.

screenshot 2022-02-24 11 09 30

maniaba and others added 4 commits February 24, 2022 07:11
Co-authored-by: kenjis <kenji.uui@gmail.com>
Co-authored-by: kenjis <kenji.uui@gmail.com>
Co-authored-by: kenjis <kenji.uui@gmail.com>
@kenjis
Copy link
Copy Markdown
Member

kenjis commented Feb 24, 2022

Your changes to the SCSS files did not match the expected CSS output.
diff --git a/system/Debug/Toolbar/Views/toolbar.css b/system/Debug/Toolbar/Views/toolbar.css
index 680ef52..11a3301 100644
--- a/system/Debug/Toolbar/Views/toolbar.css
+++ b/system/Debug/Toolbar/Views/toolbar.css
@@ -774,7 +774,8 @@
 }
 
 .debug-bar-width190p {
-  width: 190px;}
+  width: 190px;
+}
 
 .debug-bar-width20e {
   width: 20em;

https://github.com/codeigniter4/CodeIgniter4/runs/5314886769?check_suite_focus=true

@kenjis
Copy link
Copy Markdown
Member

kenjis commented Feb 24, 2022

There was 1 failure:

1) CodeIgniter\Debug\Toolbar\Collectors\HistoryTest::testSetFiles
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'1645684473.268600'
+'1645684473.2686'

/home/runner/work/CodeIgniter4/CodeIgniter4/tests/system/Debug/Toolbar/Collectors/HistoryTest.php:75
phpvfscomposer:///home/runner/work/CodeIgniter4/CodeIgniter4/vendor/phpunit/phpunit/phpunit:97

@kenjis
Copy link
Copy Markdown
Member

kenjis commented Mar 23, 2022

@maniaba
Fixing the failed tests seems to complete this PR.
Can you?

@kenjis kenjis added the stale Pull requests with conflicts label May 4, 2022
kenjis added a commit to kenjis/CodeIgniter4 that referenced this pull request May 4, 2022
@kenjis kenjis mentioned this pull request May 4, 2022
5 tasks
@kenjis
Copy link
Copy Markdown
Member

kenjis commented May 5, 2022

Closed via #5958

@kenjis kenjis closed this May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Pull requests that may break existing functionalities enhancement PRs that improve existing functionalities stale Pull requests with conflicts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants