2017 © Pedro Peláez
 

library pandalog

pandalog

image

pandalog/pandalog

pandalog

  • Monday, May 30, 2016
  • by SherlockRen
  • Repository
  • 1 Watchers
  • 2 Stars
  • 201 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

Pandalog - php日志组件

安装

$ composer require pandalog/pandalog

简易用法

<?php

use Pandalog\Logger;
use Pandalog\Handler\FileHandler;

// 创建日志对象
$log = new Logger('name', new FileHandler('path/to/your.log'));

// 支持 debug、info、notice、warning、error、critical、alert、emergency
$log->info('info');

// 更简洁的用法
$params = [
    'name' => 'test',
    'path' => '/tmp/test.log',
    'product' => 'supply', //产品名称
    'module'  => 'order' //产品模块
];
Logger::quickInit($params)->warning('test');

高级用法

<?php

use Pandalog\Logger;
use Pandalog\Handler\FileHandler;
use Pandalog\Formatter\JsonFormatter;
use Pandalog\Processor\PushProcessor;
use Pandalog\Processor\LogIdProcessor;

// 创建日志对象
$log = new Logger('name');

// 生成驱动
$handler = new FileHander();
$handler->useDaily('/tmp/test.log'); // 设置日志切割 每天切割一次
$handler->setLink('/tmp/test.log'); // 设置日志路径 不切割 setLink useDaily 二选一
$handler->setLock(false); // 关闭文件锁 默认开启
$handler->setFormatter(new JsonFormatter()); //设置内容存储格式 默认是json
$handler->handle(['test' => 'test']); //也可单独写文件使用

// 注入文件驱动
$log->pushHandler($handler);

// 注入数据处理器
$log->pushProcessor(new LogIdProcessor()); // 添加logid
$log->pushProcessor(new PushProcessor(['host_ip', 'product'], ['12312', '123'])); // 自定义存储内容

// 写入日志
$log->info('info');

Author

SherlockRen - sherlock_ren@icloud.com - https://github.com/SherlockRen
项目地址(https://github.com/SherlockRen/Pandalog), (*1)

License

Pandalog is licensed under the MIT License - see the LICENSE file for details, (*2)

The Versions

30/05 2016

dev-master

9999999-dev http://github.com/SherlockRen/Pandalog

pandalog

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar SherlockRen

log psr-3 logging

30/05 2016

1.0.6

1.0.6.0 http://github.com/SherlockRen/Pandalog

pandalog

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar SherlockRen

log psr-3 logging

11/05 2016

1.0.5

1.0.5.0 http://github.com/SherlockRen/Pandalog

pandalog

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar SherlockRen

log psr-3 logging

06/04 2016

1.0.4

1.0.4.0 http://github.com/SherlockRen/Pandalog

pandalog

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar SherlockRen

log psr-3 logging

01/04 2016

1.0.3

1.0.3.0 http://github.com/SherlockRen/Pandalog

pandalog

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar SherlockRen

log psr-3 logging

11/03 2016

1.0.2

1.0.2.0 http://github.com/SherlockRen/Pandalog

pandalog

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar SherlockRen

log psr-3 logging

18/01 2016

1.0.1

1.0.1.0 http://github.com/SherlockRen/Pandalog

pandalog

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar SherlockRen

log psr-3 logging

14/01 2016

1.0.x-dev

1.0.9999999.9999999-dev http://github.com/SherlockRen/Pandalog

pandalog

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar SherlockRen

log psr-3 logging