Seldaek / monolog

Sends your logs to files, sockets, inboxes, databases and various web services

Home Page:https://seldaek.github.io/monolog/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Firephphandler stops to work in the middle of the php file dependent on filesize of the required file.

wnedoe opened this issue · comments

Monolog version 2 last version today updated with composer

I have very weird problems with the firephp handler

After a REQUIRE of some HTML text in the php file it stops to log.
the Streamhandler continues its work

I put an exit() after that require and the behaviour stayed the same.

I checked the required file and the produced HTML code with varius tests and no error of any kind was detected.
(the Streamhandler continues to work until the end of the file)

**Now it is getting COMPLETELY BIZARRE:

If it stops to work or not is dependent on the size of the include! if i add a few characters it will stop to work!
This is the 10th include/require in thet script a- all other 9 have no problem.

So if i add ONLY A FEW characters it will stop working**

we are talking about a 3 (three) Kilobyte file. !!

This is obviously no platform dependent bug bacause it tested it on 2 completely different platforms and can reproduce it absolutely.

1.) PHP 7.4.13
XAMPP Testserver Windows 10

2.) LINUX
CENTOS 7
PHP 7.4.13

100% the same effect. :-(

What can I do to find more about the error? Any internal MONOLOG logging?
Can it be a memory problem of some kind?

############################################################################
Here is the header

HTTP/1.1 200 OK
Date: Wed, 13 Jan 2021 13:10:13 GMT
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1h PHP/7.4.13
X-Powered-By: PHP/7.4.13
X-Wf-Protocol-1: http://meta.wildfirehq.org/Protocol/JsonStream/0.2
X-Wf-1-Structure-1: http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1
X-Wf-1-Plugin-1: http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3
X-Wf-1-1-1-1: 88|[{"Type":"INFO","File":"","Line":"","Label":"terraristik"},"Monolog/Firephp is started"]|
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
X-Wf-1-1-1-2: 84|[{"Type":"INFO","File":"","Line":"","Label":"terraristik"},"C:/xampp/htdocs/locale"]|
X-Wf-1-1-1-3: 75|[{"Type":"INFO","File":"","Line":"","Label":"terraristik"},"nach requires"]|
X-Wf-1-1-1-4: 83|[{"Type":"INFO","File":"","Line":"","Label":"terraristik"},"Endgeraet ist:desktop"]|
X-Wf-1-1-1-5: 84|[{"Type":"INFO","File":"","Line":"","Label":"terraristik"},"Aktuelle user id: 1035"]|
X-Wf-1-1-1-6: 82|[{"Type":"INFO","File":"","Line":"","Label":"terraristik"},"Aktuelle Sprache: de"]|
X-Wf-1-1-1-7: 98|[{"Type":"INFO","File":"","Line":"","Label":"terraristik"},"nach head include \u00f6\u00e4\u00fc"]|
X-Wf-1-1-1-8: 80|[{"Type":"INFO","File":"","Line":"","Label":"terraristik"},"vor navbar include"]|
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked

###########################################################################################

THE STREAMHANDLER is a good dog and does anything:

content of the logfile

[2021-01-13T14:10:13.667655+01:00] terraristik.INFO: Monolog/Firephp is started [] []
[2021-01-13T14:10:13.672778+01:00] terraristik.INFO: C:/xampp/htdocs/locale [] []
[2021-01-13T14:10:13.673250+01:00] terraristik.INFO: nach requires [] []
[2021-01-13T14:10:13.674134+01:00] terraristik.INFO: Endgeraet ist:desktop [] []
[2021-01-13T14:10:13.674205+01:00] terraristik.INFO: Aktuelle user id: 1035 [] []
[2021-01-13T14:10:13.674242+01:00] terraristik.INFO: Aktuelle Sprache: de [] []
[2021-01-13T14:10:13.674618+01:00] terraristik.INFO: nach head include öäü [] []
[2021-01-13T14:10:13.674665+01:00] terraristik.INFO: vor navbar include [] []

     **all further logs are only made by the Streamhandler** 

[2021-01-13T14:10:13.675026+01:00] terraristik.INFO: nach navbar include [] []
[2021-01-13T14:10:13.675066+01:00] terraristik.INFO: SQL GUGU [] []
[2021-01-13T14:10:13.675422+01:00] terraristik.INFO: User ist 1035 [] []
[2021-01-13T14:10:13.675488+01:00] terraristik.INFO: Anzahl Anzeigen des aktuellen Users = 7 [] []

and another 400 lines ..

###############################################

the include

www.example.com Logo example.com
  • H
  •       </ul>
          <!--navbar end -->
      </div>
    
####################################################

FirephpHandler relies on being able to send HTTP headers for the logs. If you requires a HTML file without wrapping that in an output buffer, this will send some output immediately, which then prevents sending extra headers.

FirephpHandler relies on being able to send HTTP headers for the logs. If you requires a HTML file without wrapping that in an output buffer, this will send some output immediately, which then prevents sending extra headers.

OK i understand ..

But why does it work if the file is only a few bytes smaller?
Because there is some internal PHP output buffering that has a limit of 2KB or something like that?

It also works after echo "something" so in the middle of the output. :-/ ??

What would you suggest: Use a different handler like to output it to the console as this mechamism is not depending on the header?

there is indeed a php.ini setting which allows to automatically enable output buffering, and this setting can either create an unlimited buffer (as long as the memory_limit setting allows it...) or a limited buffer. The behavior you describe might be caused by a limited buffer.

What would you suggest: Use a different handler like to output it to the console as this mechamism is not depending on the header?

All handlers writing to the browser console are relying on headers to transmit the info to the browser extension AFAIK.
So if you cannot use full output buffering, I suggest you use a different way to read your logs (one where writing logs stays a backend matter)

THANK YOU 💯
After your first comment i lookd into all other handlers and now i use
the BrowserConsoleHandler which works perfectly and is not dependent on headers - the only small problem is that the formatting is always the same - info looks the same as warning and error.. but i am just looking at the source to find a solution .. as there is no real documentation on the features of this/any handler :-/