Download the PHP package webzak/uzlog without Composer
On this page you can find all versions of the php package webzak/uzlog. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package uzlog
Short Description Logging over udp
License MIT
Homepage https://github.com/webzak/uzlog-php
Informations about the package uzlog
The tiny library to send logs over UDP
Why
I had a need of something to debug the legacy projects with a quite unreadable code and complex data sructures. The idea is it should be very lightweight and have near zero impact on debugged application.
How it works
It sends the data over UDP protocol to recever: https://github.com/webzak/uzlog.
The data are sent over UDP without waiting for any confirmations from the receiver part. It works good on local machine and docker/local networks. I would not recommend to use it with open networks because the information is not encrypted.
Usage
For practical use it is easier to create a global function somewhere in the common init:
Init parameters
Socket
For socket the ip and port parameter must be set:
Transport
- max_packet - can be set for value between 21 and 508. By default it is set to 508 bytes.
Log
-
limit (int) - limits the maximum size of single log message. If the message is longer than the limit, it's tail is cut and it it indicated like [10228->5000..]. This notation means that full message length was 10228 and it was cut to 5000. The option has internal default value = 500.
-
context (int) - if value is grater than 0, the calling context is added in front of log message. The greater the value the more deeper callstack is shown. By default it is disabled. Note that this value can be set personally per message, so may be applied only when you are really interested in calling stack investigation.
- context_files (bool) - if true it additionally shows the filenames for callstack. By default it is disabled.
Saver
The saver has no init options.
Logging options
-
fg (0-255) - message foreground color. It is sent as a one byte value with a message. See ANSI escape codes
-
bg (0-255) - message background color. It is sent as one byte value with a message.
-
limit (int) - overrides the global limit parameter for concrete message.
-
transform (string) - currently supports only 'json' value. If message is array, it is transformed to json string. (Else by default arrays are transformed with print_r($a,1))
-
context - overrided the global context parameter for concrete message.
- prefix (string) - add prefix for message. This can be useful when message is a transformed structure.
Saving options
- append - if true, the data is appended to file, by default it is overwritten.
- raw - do not prettify json, when saving arrays (arrays are automatically converted to json).
Incremental filenames
The saver supports the special naming mode to generate the incremental filnames. This may be necessary when you are saving some data in loop. (The amount of '?' symbols determines the amount of digits).
The results with be saved in files:
- data.000.json
-
data.001.json
- data.nnn.json