/cuttle

:page_with_curl: A multi-module log wrapper.

Primary LanguagePHP

Cuttle

📃 A multi-module log wrapper.

Build Status Latest Stable Version Latest Unstable Version Scrutinizer Code Quality Code Coverage Total Downloads License

Requirements

  • PHP >= 7.0

Installing

$ composer require "overtrue/cuttle"

Usage

use Overtrue\Cuttle\Cuttle;

$config = [
    'default' => 'foo', // default channel
        
    'formatters' => [
        'dashed' => [
            'formatter' => \Monolog\Formatter\LineFormatter::class, // default
            'format' => "%datetime% - %channel%.%level_name% - %message%\n" 
        ],
    ],
    'handlers' => [
        'file' => [
            'handler' => \Monolog\Handler\StreamHandler::class,  // default
            'formatter' => 'dashed',
            'stream' => '/tmp/demo.log',
            'level' => 'info',
        ],
        'console' => [
            'formatter' => 'dashed',
            'stream' => 'php://stdout',
            'level' => 'debug',
        ],
    ],
    'channels' => [
        'foo' => [
            'handlers' => ['console', 'file'],
        ],
        'bar' => [
            'handlers' => ['file'], 
        ],
    ],
];

$cuttle = new Cuttle($config);

$cuttle->info('hello'); // channel: foo
$cuttle->channel('bar')->debug('debug message.');

// aslias of channel($name)
// ->of('bar')
// ->from('bar')

PHP 扩展包开发

想知道如何从零开始构建 PHP 扩展包?

请关注我的实战课程,我会在此课程中分享一些扩展开发经验 —— 《PHP 扩展包实战教程 - 从入门到发布》

License

MIT