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

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

pagon/logger
============

Pagon simple logger

0.2.0(12y ago)230621MITPHPPHP &gt;=5.3.0

Since Apr 5Pushed 12y agoCompare

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

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

Pagon Logger [![Build Status](https://camo.githubusercontent.com/c123d8f19ad609617fc17c75f88f8df3013f33f420f0ce86bac5bcd53393cba5/68747470733a2f2f7472617669732d63692e6f72672f7061676f6e2f6c6f676765722e706e67)](https://travis-ci.org/pagon/logger)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[](#pagon-logger-)

非常简单的日志库，支持debug, info, warn, error, critical等日志等级，也支持以stream的方式添加handler

依赖
--

[](#依赖)

- PHP 5.3.9+
- Composer

库依赖：

[pagon/fiber](https://github.com/pagon/fiber)

使用
--

[](#使用)

### 基本

[](#基本)

```
$logger = new \Pagon\Logger();
$logger->debug('User->%s is logged with params: %s', $username, $params);
// 2013-05-02 13:11:00 - s3f9da -   debug  - User->hfcorriez is logged with params: return=/status
$logger->info('User->:username login to homepage', array(':username' => $username))
// 2013-05-02 13:11:00 - s3f9da -   info   - User->hfcorriez login to homepage
```

### 配置

[](#配置)

```
$logger = new \Pagon\Logger(array(
    'level' => 'info',
    'file'  => '/tmp/app.log'
));
```

### 格式

[](#格式)

使用[pagon/fiber](https://github.com/pagon/fiber)实现

```
$logger = new \Pagon\Logger(array(
	'format' => '$time - $level - $text'
));
```

自定义格式参数

```
$logger = new \Pagon\Logger(array(
	'format' => '$time - $level - $file - $text'
));
$logger->file = __FILE__;
$logger->info('Some info');	// 2013-05-02 13:11:00 - info - /home/hfcorriez/myfile.php - Some info
```

### Handler

[](#handler)

目前只提供一个Console Handler用于在console输出Log信息

```
$logger = new \Pagon\Logger();
$logger->add('debug', new \Pagon\Logger\Console());
```

自定义Handler

```
class YourCustomHanlder extends \Pagon\LoggerInterface
{
    public function write()
    {
        if (empty($this->messages)) return;

        $message = join("\n", $this->buildAll()) . "\n";

        mail('your@exapmle.com', 'Some error logs', $message);
    }
}

$logger = new \Pagon\Logger();
$logger->add('error', new YourCustomHanlder());
```

### 事件

[](#事件)

```
$logger = new \Pagon\Logger();
$logger->on('flush', function() {
    // Some thing before the flush
});
```

License
-------

[](#license)

(The MIT License)

Copyright (c) 2012 hfcorriez &lt;&gt;

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity49

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

Total

2

Last Release

4644d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/052da9fcd2d35025de486c255a8b4d38a67b2626b6ca626f6681bbc00187e62b?d=identicon)[hfcorriez](/maintainers/hfcorriez)

---

Top Contributors

[![hfcorriez](https://avatars.githubusercontent.com/u/119550?v=4)](https://github.com/hfcorriez "hfcorriez (31 commits)")

---

Tags

logloggerpagon

### Embed Badge

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

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

###  Alternatives

[analog/analog

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

3451.5M24](/packages/analog-analog)[theorchard/monolog-cascade

Monolog extension to configure multiple loggers in the blink of an eye and access them from anywhere

1482.2M9](/packages/theorchard-monolog-cascade)[inpsyde/wonolog

Monolog-based logging package for WordPress.

183617.9k7](/packages/inpsyde-wonolog)[amphp/log

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

402.6M70](/packages/amphp-log)[apix/log

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

511.0M18](/packages/apix-log)[mtownsend/array-redactor

A PHP package to redact array values by their keys.

146112.3k1](/packages/mtownsend-array-redactor)

PHPackages © 2026

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