PHPackages                             sevenecks/xlog - 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. sevenecks/xlog

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

sevenecks/xlog
==============

psr3 compliant-ish logger

0.0.4(8y ago)020MITPHP

Since Mar 23Pushed 8y ago1 watchersCompare

[ Source](https://github.com/SevenEcks/xlog)[ Packagist](https://packagist.org/packages/sevenecks/xlog)[ RSS](/packages/sevenecks-xlog/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (4)Versions (5)Used By (0)

Xlog
====

[](#xlog)

[![Latest Version on Packagist](https://camo.githubusercontent.com/36bada33a4267b65a964dc4b13ab30b2cb1f1e5a0b8a022c469096596ada5738/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736576656e65636b732f786c6f672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sevenecks/xlog)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/601c6bbaf8a7b0be7a643cd50e515cfd658dc2b77bec2df4caa13a9d5f0e9db1/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f736576656e65636b732f786c6f672f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/sevenecks/xlog)[![Coverage Status](https://camo.githubusercontent.com/4d4ec4586441063fe04b3254cfcddb96683f4dc12a12835d9957e021dce29924/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f736576656e65636b732f786c6f672e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/sevenecks/xlog/code-structure)[![Quality Score](https://camo.githubusercontent.com/85030bd0a68ea155eb4bdceeb03c8ff641010b422ba0a8747f1424b38431d1f2/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f736576656e65636b732f786c6f672e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/sevenecks/xlog)[![Total Downloads](https://camo.githubusercontent.com/94e08f2dcedc526726efc4849129221b6bf7bbcf6cca22cfe3b2003dd639ba8a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736576656e65636b732f786c6f672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sevenecks/xlog)

A psr-3 compliant logging module with color support for each different logging level.

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

[](#installation)

Via Composer

```
composer require sevenecks/xlog
```

Usage
-----

[](#usage)

```
require_once __DIR__ . '/vendor/autoload.php';
require('src/Logger.php');

use SevenEcks\Xlog\Logger;

$xlog = new Logger;;
$xlog->clearLog();
$xlog->emergency('test');
$xlog->alert('test');
$xlog->critical('test');
$xlog->error('test');
$xlog->warning('test');
$xlog->notice('test');
$xlog->info('test');
$xlog->debug('test');
```

### Bash Usage

[](#bash-usage)

After logging some stuff you can cat your log file and see all the pretty colors.

```
cat xlog.log
```

### Colors

[](#colors)

All colors are created using ANSI color codes from Colorizer that is a part of this [ANSI](https://github.com/SevenEcks/ansi) module.

```
Emergency => Red
Alert => Light Red
Critical => Purple
Error => Light Purple
Warning => Yellow
Notice => Light Gray
Info => White
Debug => Cyan

```

API
---

[](#api)

The [PSR-3 Logger Interface](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md) defines the core of the API that this logging package uses.

```
/**
 * System is unusable.
 *
 * @param string $message
 * @param array $context
 * @return void
 */
public function emergency($message, array $context = array());

/**
 * Action must be taken immediately.
 *
 * Example: Entire website down, database unavailable, etc. This should
 * trigger the SMS alerts and wake you up.
 *
 * @param string $message
 * @param array $context
 * @return void
 */
public function alert($message, array $context = array());

/**
 * Critical conditions.
 *
 * Example: Application component unavailable, unexpected exception.
 *
 * @param string $message
 * @param array $context
 * @return void
 */
public function critical($message, array $context = array());

/**
 * Runtime errors that do not require immediate action but should typically
 * be logged and monitored.
 *
 * @param string $message
 * @param array $context
 * @return void
 */
public function error($message, array $context = array());

/**
 * Exceptional occurrences that are not errors.
 *
 * Example: Use of deprecated APIs, poor use of an API, undesirable things
 * that are not necessarily wrong.
 *
 * @param string $message
 * @param array $context
 * @return void
 */
public function warning($message, array $context = array());

/**
 * Normal but significant events.
 *
 * @param string $message
 * @param array $context
 * @return void
 */
public function notice($message, array $context = array());

/**
 * Interesting events.
 *
 * Example: User logs in, SQL logs.
 *
 * @param string $message
 * @param array $context
 * @return void
 */
public function info($message, array $context = array());

/**
 * Detailed debug information.
 *
 * @param string $message
 * @param array $context
 * @return void
 */
public function debug($message, array $context = array());

/**
 * Logs with an arbitrary level.
 *
 * @param mixed $level
 * @param string $message
 * @param array $context
 * @return void
 */
public function log($level, $message, array $context = array());
```

On top of that functionality is the ability to use dependency injection to configure the logging object, via constructor injection:

```
public function __construct($file_name = 'xlog.log', $append_to_file = true, $string_utils = null, ColorInterface $colorize = null)
```

The constructor takes the file name, the $append\_to\_file (it should probably always be on), the $string\_utils object, and the ColorInterface object. If none of these are provided, the constructor will create them based on the defaults. If you are happy with the module as it is, you don't need to pass any constructor arguments aside from perhaps the $file\_name.

```
/**
 * Clear the log file
 *
 * @return int
 */
public function clearLog()
```

This will clear the log file. It can be called after object instantiation if you want a fresh log, or really at any point.

ToDo
----

[](#todo)

1. Add ability for capped logs, where the log automatically prunes older items after a certain amount of rows

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](CODE_OF_CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Brendan Butts](https://github.com/sevenecks)
- [All Contributors](../../contributors)

Change Log
----------

[](#change-log)

Please see [Change Log](CHANGELOG.md) for more information.

License
-------

[](#license)

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

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.2% 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 ~6 days

Total

4

Last Release

2951d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/963368d2aa1a4a1bf29571edf1377016ec16104a567abd89075b78f0edbf0925?d=identicon)[sevenecks](/maintainers/sevenecks)

---

Top Contributors

[![BrendanAlipes](https://avatars.githubusercontent.com/u/40271827?v=4)](https://github.com/BrendanAlipes "BrendanAlipes (15 commits)")[![sevenecks](https://avatars.githubusercontent.com/u/2490474?v=4)](https://github.com/sevenecks "sevenecks (2 commits)")

---

Tags

colorloggingphppsr3

###  Code Quality

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/sevenecks-xlog/health.svg)

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

###  Alternatives

[sentry/sentry

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

1.9k227.1M271](/packages/sentry-sentry)[rollbar/rollbar

Monitors errors and exceptions and reports them to Rollbar

33723.7M81](/packages/rollbar-rollbar)[illuminate/log

The Illuminate Log package.

6224.3M517](/packages/illuminate-log)[open-telemetry/sdk

SDK for OpenTelemetry PHP.

2222.9M248](/packages/open-telemetry-sdk)[open-telemetry/api

API for OpenTelemetry PHP.

1833.0M214](/packages/open-telemetry-api)[pagemachine/typo3-formlog

Form log for TYPO3

23225.3k6](/packages/pagemachine-typo3-formlog)

PHPackages © 2026

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