# Panel hooks logging extremely slow in 2.3.2

**URL:** <https://forum.getkirby.com/t/panel-hooks-logging-extremely-slow-in-2-3-2/4916>\
**Category:** Questions\
**Tags:** v2\
**Created:** [August 8, 2016, 2:06pm UTC](https://forum.getkirby.com/t/panel-hooks-logging-extremely-slow-in-2-3-2/4916 "2016-08-08T14:06:05Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![krisa](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/krisa/32/3415_2.png) [@krisa](https://forum.getkirby.com/u/krisa)\
**Post date:** [August 8, 2016, 2:06pm UTC](https://forum.getkirby.com/t/panel-hooks-logging-extremely-slow-in-2-3-2/4916/1 "2016-08-08T14:06:05Z")

</div>

Hi, ive seen many issues about this. Most of them claimed that its solved so i am probably doing something wrong.

This takes ages in panel:

```php
kirby()->hook(['panel.page.create', 'panel.page.update'], function($page) {
$file = kirby()->roots()->config() . DS . 'log.txt';
	  $current .= $page->uid() . "\n";
	  f::write($file, $current, true);
});

```

So what iam doing wrong? Kirby is updated to 2.3.2

I guess writing to file is not the most efficient thing to do but still it shouldn’t take this much time.

What would be more efficient way to log updated files? I need this log. Thx

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [August 8, 2016, 2:14pm UTC](https://forum.getkirby.com/t/panel-hooks-logging-extremely-slow-in-2-3-2/4916/2 "2016-08-08T14:14:23Z")

</div>

Is it the issue that the loading bar at the top loads and loads forever? From which Kirby version did you upgrade?

There’s a typo in your code, maybe that solves it already:

```auto
kirby()->hook(['panel.page.create', 'panel.page.update'], function($page) {
	$file = kirby()->roots()->config() . DS . 'log.txt';
	$current = $page->uid() . "\n"; // <-- The dot before the = sign needs to be removed
	f::write($file, $current, true);
});

```

---

<div class="post-metadata">

**Author:** ![krisa](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/krisa/32/3415_2.png) [@krisa](https://forum.getkirby.com/u/krisa)\
**Post date:** [August 9, 2016, 7:54am UTC](https://forum.getkirby.com/t/panel-hooks-logging-extremely-slow-in-2-3-2/4916/3 "2016-08-09T07:54:13Z")

</div>

AAAAHH stupid typo. It seems it is solved.

Thank you!

Strangely i had same issue when i wanted to write straight to database.

Anyways THX!

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [August 9, 2016, 8:59am UTC](https://forum.getkirby.com/t/panel-hooks-logging-extremely-slow-in-2-3-2/4916/4 "2016-08-09T08:59:37Z")

</div>

It looks like this issue occurs when a hook produces some kind of output (a PHP warning/notice etc.).

---

<div class="post-metadata">

**Author:** ![jenstornell](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jenstornell/32/546_2.png) [@jenstornell](https://forum.getkirby.com/u/jenstornell)\
**Post date:** [August 9, 2016, 10:03am UTC](https://forum.getkirby.com/t/panel-hooks-logging-extremely-slow-in-2-3-2/4916/5 "2016-08-09T10:03:46Z")

</div>

Would it be possible to output these kind of messages in a modal to the user instead of hang the panel?

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [August 9, 2016, 10:16am UTC](https://forum.getkirby.com/t/panel-hooks-logging-extremely-slow-in-2-3-2/4916/6 "2016-08-09T10:16:47Z")

</div>

Output in hooks is not intended and this won’t work because the Panel frontend expects a JSON response. If there’s some kind of other output, it breaks the JSON.

---

<div class="post-metadata">

**Author:** ![jenstornell](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jenstornell/32/546_2.png) [@jenstornell](https://forum.getkirby.com/u/jenstornell)\
**Post date:** [August 9, 2016, 10:28am UTC](https://forum.getkirby.com/t/panel-hooks-logging-extremely-slow-in-2-3-2/4916/7 "2016-08-09T10:28:07Z")

</div>

I see. It’s a difficult to have a smooth debug experience with the hooks of today.

Would it be possible to return as html and convert the response on the PHP side? Then a simple validation could be made to see if it’s a JSON. If not, output an error message in a modal, if for example debug mode is true in the config.

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [August 9, 2016, 11:15am UTC](https://forum.getkirby.com/t/panel-hooks-logging-extremely-slow-in-2-3-2/4916/8 "2016-08-09T11:15:56Z")

</div>

That’s sounds a bit error-prone. What could work though is to capture output from the hooks using PHP’s output buffer and if that output is not empty tell the frontend to display it in a modal. Not sure how complex that is however.

---

<div class="post-metadata">

**Author:** ![jenstornell](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jenstornell/32/546_2.png) [@jenstornell](https://forum.getkirby.com/u/jenstornell)\
**Post date:** [August 12, 2016, 6:15pm UTC](https://forum.getkirby.com/t/panel-hooks-logging-extremely-slow-in-2-3-2/4916/9 "2016-08-12T18:15:15Z")

</div>

You just gave me a plugin idea. 🙂

---

<div class="post-metadata">

**Author:** ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)\
**Post date:** [February 6, 2025, 4:57pm UTC](https://forum.getkirby.com/t/panel-hooks-logging-extremely-slow-in-2-3-2/4916/10 "2025-02-06T16:57:20Z")

</div>

Archived on February 6, 2025, 4:57pm UTC


