PHPackages                             webzak/uzlog - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. webzak/uzlog

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

webzak/uzlog
============

Logging over udp

1.1.0(6y ago)03MITPHPPHP &gt;=7.1.0CI failing

Since Nov 17Pushed 5y ago1 watchersCompare

[ Source](https://github.com/webzak/uzlog-php)[ Packagist](https://packagist.org/packages/webzak/uzlog)[ Docs](https://github.com/webzak/uzlog-php)[ RSS](/packages/webzak-uzlog/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

The tiny library to send logs over UDP
======================================

[](#the-tiny-library-to-send-logs-over-udp)

Why
---

[](#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
------------

[](#how-it-works)

It sends the data over UDP protocol to recever: .

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
-----

[](#usage)

```
use Webzak\Uzlog\{Socket, Transport, Log, Saver};

$socket = new Socket('127.0.0.1', 7000);
$transport = new Transport($socket);
$log = new Log($transport);
$saver = new Saver($transport);

$log->send("Hello");
$saver->send('servinfo.json', $_SERVER);
```

For practical use it is easier to create a global function somewhere in the common init:

```
use Webzak\Uzlog;

#define UZL_HOST 127.0.0.1
#define UZL_PORT 7000
#define UZL_MAX_MSG_LEN 5000

function ulog($msg, array $opts = [])
{
    static $client;

    if (!is_null($client)) {
        return $client->send($msg, $opts);
    } elseif ($msg instanceof \Udplog\Log) {
        $client = $msg;
    }
}

// init the instance
ulog(new Uzlog\Log(new Uzlog\Transport(new Uzlog\Socket(UZL_HOST, UZL_PORT), ['limit' => UZL_MAX_MSG_LEN]));

// then just use it anywhere
ulog("Hello!", ['fg' => 21, 'bg' => 46]);
```

Init parameters
---------------

[](#init-parameters)

### Socket

[](#socket)

For socket the ip and port parameter must be set:

```
$socket = new Uzlog\Socket('172.17.0.1', 7777);
```

### Transport

[](#transport)

- **max\_packet** - can be set for value between 21 and 508. By default it is set to 508 bytes.

```
$transport = new Uzlog\Transport($socket, ['max_packet' => 200]);
```

### Log

[](#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-&gt;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.

```
$log = new Uzlog\Log($transport, ['limit' => 2000, 'context' => 10]);
```

### Saver

[](#saver)

The saver has no init options.

```
$saver = new Uzlog\Saver($transport);
```

Logging options
---------------

[](#logging-options)

- **fg** (0-255) - message foreground color. It is sent as a one byte value with a message. See [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit)
- **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.

```
$log->send($msg1);
$log->send($msg2, ['fg' => 21, 'bg' => 46]);
$log->send($msg3, ['limit' => 5000, 'context' => true]);
$log->send($arr, ['transform' => 'json']);
$log->send($arr, ['prefix' => 'ERR:']);
```

Saving options
--------------

[](#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).

```
$saver->send('file.txt', 'somestring');
$saver->send('data.json', $array, ['raw' => true]);
$saver->send('data.csv',  $row, ['append' => true]);
```

### Incremental filenames

[](#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).

```
foreach($x as $data) {
    $saver->send('data.???.json', $data);
}
```

The results with be saved in files:

- data.000.json
- data.001.json
- data.nnn.json

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

2373d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2851105?v=4)[webzak](/maintainers/webzak)[@webzak](https://github.com/webzak)

---

Top Contributors

[![webzak](https://avatars.githubusercontent.com/u/2851105?v=4)](https://github.com/webzak "webzak (1 commits)")

---

Tags

loglogging

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/webzak-uzlog/health.svg)

```
[![Health](https://phpackages.com/badges/webzak-uzlog/health.svg)](https://phpackages.com/packages/webzak-uzlog)
```

###  Alternatives

[monolog/monolog

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

21.4k964.9M7.0k](/packages/monolog-monolog)[symfony/monolog-bundle

Symfony MonologBundle

2.9k249.1M1.6k](/packages/symfony-monolog-bundle)[sentry/sentry

PHP SDK for Sentry (http://sentry.io)

1.9k227.1M273](/packages/sentry-sentry)[sentry/sentry-laravel

Laravel SDK for Sentry (https://sentry.io)

1.3k114.3M154](/packages/sentry-sentry-laravel)[rap2hpoutre/laravel-log-viewer

A Laravel log reader

3.2k14.7M71](/packages/rap2hpoutre-laravel-log-viewer)[sentry/sdk

This is a meta package of sentry/sentry. We recommend using sentry/sentry directly.

327134.8M151](/packages/sentry-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
