2017 © Pedro Peláez
 

library log

volador log

image

volador2/log

volador log

  • Monday, January 16, 2017
  • by huangchao
  • Repository
  • 1 Watchers
  • 1 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Volador2 Log

依赖:

  • volador2/helpers

说明

配置日志模版和处理外部数据

<?php

use Volador\Log\Logger;
use Volador\Log\LogConfig;

class Bootstrap
{
    function ___init() {
        LogConfig::logfile("/var/log/a.log");
        LogConfig::template("{DATETIME} [{REQUEST_ID}][{LEVEL}] {FILE}:{LINE} {CONTENT}");

        // 设置日志模版中KEY的值
        LogConfig::setTemplateVal('REQUEST_ID', $REQUEST_ID);
    }
}

记录日志

use Volador\Log\Logger;
class DemoController
{
    function indexAction()
    {
        Logger::debug('hello, {name}', ['name' => 'Lin{name}']);
    }
}

常驻进程

use Volador\Log\Logger;
use Volador\Log\LogConfig;

class Daemon
{

    function __construct()
    {
        LogConfig::logfile('/path/debug.log');
        LogConfig::template('{DATETIME} [{REQUEST_ID}][{LEVEL}] {FILE}:{LINE} {CONTENT}');
    }

    public function run()
    {
        for (;;) { 
            LogConfig::setTemplateVal('REQUEST_ID', $REQUEST_ID);
            Logger::debug('hello, {name}', ['name' => 'Lin{name}']);

            Logger::fflush();
        }
    }
}


API 函数列表

当出现致命的运行时错误。这类错误一般是不可恢复的情况。后果是导致脚本终止不再继续运行。, (*1)

Logger::fatal($message, array $context = array())

运行时警告 (非致命错误)。仅给出提示信息,但是脚本不会终止运行。, (*2)

Logger::warning($message, array $context = array())

表示遇到可能会表现为错误的情况,但是在可以正常运行的脚本里面也可能会有类似的通知。, (*3)

Logger::notice($message, array $context = array())

用于帮助调试和查找问题。, (*4)

Logger::debug($message, array $context = array())

立即写盘并释放当前日志文件, (*5)

Logger::fflush()

The Versions

16/01 2017

dev-master

9999999-dev

volador log

  Sources   Download

MIT

The Requires

 

by Avatar huangchao

log volador

16/01 2017

v1.0.170116

1.0.170116.0

volador log

  Sources   Download

MIT

The Requires

 

by Avatar huangchao

log volador