PHPackages                             serhii/tiny-logger - 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. serhii/tiny-logger

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

serhii/tiny-logger
==================

Light weight composer package for file logging in PHP7.

2.3.0(5mo ago)7355MITPHPPHP ^7.2|^8.0CI failing

Since Dec 25Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/tiny-logger/tiny-logger)[ Packagist](https://packagist.org/packages/serhii/tiny-logger)[ Docs](https://github.com/tiny-logger/tiny-logger)[ RSS](/packages/serhii-tiny-logger/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (26)Used By (0)

[![Tiny Logger](https://github.com/tiny-logger/tiny-logger/actions/workflows/php.yml/badge.svg?branch=master)](https://github.com/tiny-logger/tiny-logger/actions/workflows/php.yml)[![Latest Stable Version](https://camo.githubusercontent.com/7af6a5ce70a60dd6ec844fb8d8e61d16dfac0b5d32048aca4ae66d9085727f47/68747470733a2f2f706f7365722e707567782e6f72672f7365726869692f74696e792d6c6f676765722f762f737461626c65)](https://packagist.org/packages/serhii/tiny-logger)[![Total Downloads](https://camo.githubusercontent.com/2bf839ab564dcb73731d4c35706a2145aaae0bf65c0147168fb4598c11990fd8/68747470733a2f2f706f7365722e707567782e6f72672f7365726869692f74696e792d6c6f676765722f646f776e6c6f616473)](https://packagist.org/packages/serhii/tiny-logger)[![License](https://camo.githubusercontent.com/502a76d20f65364803c0ffd5724a02a1e7a2e5406ab38239ea520f934e81a2ec/68747470733a2f2f706f7365722e707567782e6f72672f7365726869692f74696e792d6c6f676765722f6c6963656e7365)](https://packagist.org/packages/serhii/tiny-logger)[![Minimum PHP Version](https://camo.githubusercontent.com/4c62148864d567c4ee794ffab09c1dd4a3f45e41064bbb016440beddaae71a4d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230372e322d3838393242462e737667)](https://php.net/)

Lightweight composer package for file logging with ability to send errors with webhook.

[Usage example](https://replit.com/@SerhiiCho/Usage-of-tiny-logger-package#public/index.php)

Set file path
-------------

[](#set-file-path)

For setting up the path globally for all the log files you can call `setPath` method in your bootstrap file.

```
use Serhii\TinyLogger\Logger;

Logger::setPath('logs/errors.log'); // simple format
Logger::setPath('logs/%s.log', 'errors'); // sprintf format
```

> NOTE: If you want to use logger in a cron scripts or something like WordPress hook, you need to call `setPath()` at the very first step of the script execution, it means that your project might have multiple places where you need to set path for your logs. If you don't want to call `setPath()` you can just pass the path to a `tiny_log()` function as a third argument. *See an example in the Usage section.*

Supported PHP versions
----------------------

[](#supported-php-versions)

- ✅ 7.2
- ✅ 7.3
- ✅ 7.4
- ✅ 8.0
- ✅ 8.1
- ✅ 8.2
- ✅ 8.3
- ✅ 8.4
- ✅ 8.5

Usage
-----

[](#usage)

This package comes with a function `tiny_log()` where second and third arguments are not required.

```
tiny_log('Some error message');
// Output in file: [2020-01-12 04:09:16] error: Some error message.

tiny_log('Some error message', 'info');
// Output in file: [2020-01-12 04:09:16] info: Some error message.

tiny_log('Some error message', 'debug', 'logs/debug.log');
// If you don't need to set path globally, just pass file path as the third argument to the tiny_log function .
```

You can also use Logger class if you want. It will do the same as using function.

```
use \Serhii\TinyLogger\Logger;

Logger::new()->error('Some error message');
Logger::new()->info('Some info message');
Logger::new()->debug('Some error message');
```

Options
-------

[](#options)

For using one of the available options you can optionally pass certain flag to `tiny_log()` function as the second argument. If you also need to pass error type just separate them with the pipe `|` character. See the example with option `pos`:

```
tiny_log('Some error message', 'pos'); // just passing option
tiny_log('Some error message', 'pos|error'); // 'pos' option with error type 'error'
tiny_log('Some error message', 'pos|info'); // 'pos' option with error type 'info'
```

#### Available options

[](#available-options)

- `pos` - Show position of the logger. In which file and on what line number it is. It is useful when you're debugging, to not forget where you put your logger. See the example of output:

```
[2020-01-12 04:09:16] info: Some log message goes here
>>> /var/www/html/app/Services/App.php on line: 77.

```

Send logs with POST request
---------------------------

[](#send-logs-with-post-request)

Tiny logger allows you to send logs as a json object on a specific endpoint. To enable this option you need to call `enablePostRequest` method on `Logger` class. To disable POST request use `disablePostRequest` method.

```
use Serhii\TinyLogger\Logger;

Logger::enablePostRequest('http://my-site.com/webhook');
```

Now if error occurs, json will be sent to `http://my-site.com/webhook` endpoint with POST request.

```
{
    "timestamp": "1611675632",
    "message": "Undefined variable at line 24 in \\App\\Models\\User class.",
    "type": "error"
}
```

If you need to customize the json object structure, you can pass array as the second argument on `enablePostRequest` method.

```
use Serhii\TinyLogger\JsonFieldValue;
use Serhii\TinyLogger\Logger;

Logger::enablePostRequest('http://my-site.com/webhook', [
    'time' => JsonFieldValue::TIMESTAMP,
    'errorMessage' => 'Error message: ' . JsonFieldValue::MESSAGE,
    'errorType' => JsonFieldValue::ERROR_TYPE,
    'token' => getenv('MY_AUTH_TOKEN')
]);
```

Now you'll get json like this:

```
{
    "time": "1611675632",
    "errorMessage": "Error message: Undefined variable at line 24 in \\App\\Models\\User class.",
    "errorType": "error",
    "token": "29d62x7g656e6f9"
}
```

Each JsonFieldValue constant will be replaced with its value. For example JsonFieldValue::MESSAGE will be replaced with the error message. JsonFieldValue::TIMESTAMP will be replaced with error timestamp.

> NOTE: If you want to use logger in a cron scripts or something like WordPress hook, you need to call `enablePostRequest` at the very first step of the script execution.

Get started
-----------

[](#get-started)

To install all php dependencies you need to have [Composer PHP package manager](https://getcomposer.org) installed on your machine. Then you need to run the command below in your root directory of the project.

```
composer require serhii/tiny-logger
```

Contribute
----------

[](#contribute)

### With a Container Engine

[](#with-a-container-engine)

#### Build an Image

[](#build-an-image)

To build an image, navigate to the root of the project and run this command.

With Podman:

```
podman-compose build
```

With Docker:

```
docker compose build
```

#### Run the Container

[](#run-the-container)

To run the container, navigate to the root of the project and run this command.

With Podman:

```
podman-compose run --rm app
```

With Docker:

```
docker compose run --rm app
```

#### Destroy the Container

[](#destroy-the-container)

You can cleanup after working on a project by destroying things like networks with this command.

With Podman:

```
podman-compose down
```

With Docker:

```
docker compose down
```

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance74

Regular maintenance activity

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity72

Established project with proven stability

 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 ~90 days

Recently: every ~97 days

Total

25

Last Release

172d ago

Major Versions

1.4.2 → 2.02020-12-08

PHP version history (3 changes)1.0PHP ^7.0

1.3PHP ^7.1

v2.1.0PHP ^7.2|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/492847fa1c01ef11bfb489695d1d8553d4729f59efce19b34b8ed4b0f3598fae?d=identicon)[SerhiiCho](/maintainers/SerhiiCho)

---

Top Contributors

[![SerhiiCho](https://avatars.githubusercontent.com/u/35465417?v=4)](https://github.com/SerhiiCho "SerhiiCho (176 commits)")

---

Tags

composerlogloggerpackagistphpphp-librarylibrarylogger

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/serhii-tiny-logger/health.svg)

```
[![Health](https://phpackages.com/badges/serhii-tiny-logger/health.svg)](https://phpackages.com/packages/serhii-tiny-logger)
```

###  Alternatives

[justbetter/magento2-sentry

Magento 2 Logger for Sentry

1851.5M3](/packages/justbetter-magento2-sentry)[marvinlabs/laravel-discord-logger

Logging to a discord channel in Laravel

2081.1M2](/packages/marvinlabs-laravel-discord-logger)[amphp/log

Non-blocking logging for PHP based on Amp, Revolt, and Monolog.

402.6M70](/packages/amphp-log)[logtail/monolog-logtail

Logtail handler for Monolog

233.2M3](/packages/logtail-monolog-logtail)[bref/logger

All you need to log with Bref on AWS Lambda

331.5M8](/packages/bref-logger)

PHPackages © 2026

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