PHPackages                             faslatam/log - 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. faslatam/log

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

faslatam/log
============

Small log file writer with adjustable log level settings.

v2.0.0(2y ago)04MITPHP

Since Nov 9Pushed 2y agoCompare

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

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Forestry Log
============

[](#forestry-log)

[![Latest Version](https://camo.githubusercontent.com/98021b91c0657157734e8b868d311b093644b91ae065eea5e369df48934f4bb8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6661647269616e30362f6c6f672e7376673f7374796c653d666c61742d737175617265)](https://github.com/fadrian06/log/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/18b26ffee786240df0684682b45f209008ff4655cbc48a17763312ce8074dca7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6661736c6174616d2f6c6f672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/faslatam/log)

Small log file writer with adjustable log level threshold settings.

Install
-------

[](#install)

Via Composer

```
$ composer require faslatam/log
```

Usage
-----

[](#usage)

### Creating a logger

[](#creating-a-logger)

```
$logger = new Forestry\Log\Log('/tmp/dummy.log');
//Just log notices and above.
$errorLog = new Forestry\Log\Log('./logs/error.log', Psr\Log\LogLevel::NOTICE);
```

#### Using a factory

[](#using-a-factory)

Another way to create an instance is the use of one of the factories. There is one for each threshold level.

Here is an example for a logger with an error threshold:

```
$factory = new ErrorLogger();
$logger = $factory->create('/tmp/error.log');
```

### Log a message

[](#log-a-message)

Forestry\\Log provides methods for the log levels defined by RFC 5424 (debug, info, notice, warning, error, critical, alert and emergency). There's a method for each of these levels:

```
$logger->emergency('This is an emergency message');
$logger->alert('This is an alert message');
$logger->critical('This is an critical message');
$logger->error('This is an error message');
$logger->warning('This is an warning message');
$logger->notice('This is a notice message');
$logger->info('This is an information');
$logger->debug('This is a debug message');
```

You can also use a generic `log` method:

```
$logger->log(Psr\Log\LogLevel::DEBUG, 'this is a debug message');
```

#### Using placeholders in log messages

[](#using-placeholders-in-log-messages)

You can use placeholders in the your message string and fill them using the associative context array. The array keys have to match the placeholders without the curly brackets:

```
$user = ['name' => 'John Doe', 'mail' => 'j.doe@example.org'];
$logger->info('Send mail to {name} ({mail})', $user); // Send mail to John Doe (j.doe@example.org)
```

### Change the date format

[](#change-the-date-format)

The default date format is `Y-m-d H:i:s`. You can change it by using the `setDateFormat` method:

```
$logger->setDateFormat('r'); // e.g. Thu, 21 Dec 2000 16:01:07 +0200
```

This method accepts any string which is compatible with PHPs native `date()`.

### Change the message format

[](#change-the-message-format)

The default format for the log message is `date level message`. To change it, you can re-arrange the placeholders with `setLogFormat`:

```
$logger->setLogFormat('[{level}|{date}] {message}'); // [INF0|2013-04-25 13:37:42] This is an info message
```

There are the following placeholder available:

- {date}
- {level}
- {message}

These placeholders will be replaced with ones for `sprintf()`, so you can also use the following:

- `%1$s` = date
- `%2$s` = level
- `%3$s` = message

### Change the threshold level of an existing instance

[](#change-the-threshold-level-of-an-existing-instance)

To change the threshold level of an existing instance, use the `setLogThreshold` method:

```
$logger->setLogThreshold(Psr\Log\LogLevel::DEBUG);
```

### Get current logging level

[](#get-current-logging-level)

To get the current threshold level of an existing instance, use the `getLogThreshold` method:

```
$level = $logger->getLogThreshold();
$logger->setLogThreshold(Psr\Log\LogLevel::INFO);
$logger->logInfo('my info');
$logger->setLogThreshold($level);
```

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [daniel-melzer](https://github.com/daniel-melzer)
- [fadrian06](https://github.com/fadrian06)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.3% 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

Unknown

Total

1

Last Release

917d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/37f9864d589abf634aa9a44b9aec1f644adf3104e01812da202ac4c1c860957d?d=identicon)[fadrian06](/maintainers/fadrian06)

---

Top Contributors

[![daniel-melzer](https://avatars.githubusercontent.com/u/389719?v=4)](https://github.com/daniel-melzer "daniel-melzer (21 commits)")[![fadrian06](https://avatars.githubusercontent.com/u/109766973?v=4)](https://github.com/fadrian06 "fadrian06 (2 commits)")

---

Tags

logpsr-3loggingforestry

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/faslatam-log/health.svg)

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

###  Alternatives

[monolog/monolog

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

21.4k964.9M7.0k](/packages/monolog-monolog)[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)[apix/log

Minimalist, thin and fast PSR-3 compliant (multi-bucket) logger.

511.0M18](/packages/apix-log)[elastic/ecs-logging

Format and enrich your log files in the elastic common schema

21907.5k1](/packages/elastic-ecs-logging)[markrogoyski/simplelog-php

Powerful PSR-3 logging. So easy, it's simple.

2818.1k4](/packages/markrogoyski-simplelog-php)

PHPackages © 2026

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