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

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

juanchosl/logger
================

Little logger using the PSR interfaces

1.1.3(3mo ago)1365↓100%5MITPHPPHP ^8.1

Since Jun 26Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/JuanchoSL/Logger)[ Packagist](https://packagist.org/packages/juanchosl/logger)[ Docs](https://github.com/JuanchoSL/Logger)[ RSS](/packages/juanchosl-logger/feed)WikiDiscussions 1.1 Synced 1mo ago

READMEChangelog (8)Dependencies (3)Versions (12)Used By (5)

Logger
======

[](#logger)

Description
-----------

[](#description)

Little adapter to save log data using PSR3. This library have the availability of put the data log into distincts repositories or with different format. We can change the destination of the data, or his format, only changing the injected dependency.

We can create distincts log for differents cases, save it with an alias into the Debugger instance and call or inject any one into a any lib. In example, we can create a log for database queries, other for debug, other for errors...

Installation
------------

[](#installation)

Use composer in order to install it

```
composer require juanchosl/logger
composer update
```

How to use
----------

[](#how-to-use)

### First steps

[](#first-steps)

#### Create or use provided Data Composers,

[](#create-or-use-provided-data-composers)

Using composers, you can create and design your own messages structure, you can convert to String (for save into files) or can convert to Array or Objects in order to save into tables.

Actually we have availables 3 types of Composers:

- TextComposer
- ArrayComposer
- ObjectComposer

```
$composer = new TextComposer;
```

#### Create or use a provided repository

[](#create-or-use-a-provided-repository)

Is the message destination, you can use the same Composer for save data to few Repositories, mantaining the same structure for all, create an instance in order to put the composer

Actually we have availables 3 Repositories

- FileRepository (needs to provide a filepath)
- ScreenRepository (do ECHO, converting iterable entities with print\_r, json\_encode, casting to string or performing a var\_dump)
- StreamRepository, as Screen, convert variables, capturing it and send to a stream, as a body from a PSR Response

```
$repository = new FileRepository(PATH . DIRECTORY_SEPARATOR . 'error.log');
$repository->setComposer($composer);
```

### Logger

[](#logger-1)

#### Declare a Logger directly

[](#declare-a-logger-directly)

```
$logger = new JuanchoSL\Logger\Logger($repository);
$logger->error("This is a message error");
```

#### Declare a Logger using the provided Debugger class

[](#declare-a-logger-using-the-provided-debugger-class)

```
use JuanchoSL\Logger\Debugger;

$debugger = Debugger::init();
$debugger->setLogger('errors', $logger);

//.... your code ...

Debugger::get('errors')->error("This is a message error");
```

#### Declaring few Loggers in order to save separated data

[](#declaring-few-loggers-in-order-to-save-separated-data)

```
use JuanchoSL\Logger\Debugger;

$debugger = Debugger::init()
    ->setLogger('errors', $logger)
    ->setLogger('database', new Logger((new ModelRepository())->setComposer(new ObjectComposer)));

//.... your code ...

Debugger::get('errors')?->error("This is a message error");
Debugger::get('database')?->debug($sql);
```

### Error control

[](#error-control)

#### Initializing error or exception handlers

[](#initializing-error-or-exception-handlers)

```
use JuanchoSL\Logger\Debugger;

$debugger = Debugger::init()->setLogger('errors', $logger)->initFailuresHandler('errors', E_ALL^E_USER_NOTICE);
```

### Use declared Loggers for inject as dependecy into Libraries

[](#use-declared-loggers-for-inject-as-dependecy-into-libraries)

```
use JuanchoSL\Logger\Debugger;
use JuanchoSL\Orm\Engine\Drivers\Mysqli;

$debugger = Debugger::init()
    ->setLogger('errors', $logger)
    ->setLogger('database', new Logger((new ModelRepository())->setComposer(new ObjectComposer)))
    ->initFailuresHandler('errors', E_ALL^E_USER_NOTICE);

$database = new Mysqli($credentials);
$database->setLogger($debugger->getLogger('database'));
```

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance78

Regular maintenance activity

Popularity15

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity59

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

Total

10

Last Release

118d ago

PHP version history (2 changes)1.0.0PHP ^7.1 || ^8.0

1.1.1PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/bd6d3dea7eb469817524c42a80683e95793ed4800a6794366503355af046a726?d=identicon)[Juanchosl](/maintainers/Juanchosl)

---

Top Contributors

[![JuanchoSL](https://avatars.githubusercontent.com/u/18701207?v=4)](https://github.com/JuanchoSL "JuanchoSL (68 commits)")

---

Tags

logdebug

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[sentry/sentry

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

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

Fast, flexible, easy PSR-3-compatible PHP logging package with dozens of handlers.

3451.5M24](/packages/analog-analog)[inpsyde/wonolog

Monolog-based logging package for WordPress.

183617.9k7](/packages/inpsyde-wonolog)[pagemachine/typo3-formlog

Form log for TYPO3

23225.3k6](/packages/pagemachine-typo3-formlog)[baibaratsky/yii2-rollbar

Rollbar for Yii2

35130.5k](/packages/baibaratsky-yii2-rollbar)[snapshotpl/zf-snap-php-debug-bar

PHP Debug Bar module for Zend Framework 2

3026.1k](/packages/snapshotpl-zf-snap-php-debug-bar)

PHPackages © 2026

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