Download the PHP package fengxinyhyl/logger without Composer

On this page you can find all versions of the php package fengxinyhyl/logger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package logger

logger


安装方式

项目依赖

"require": {
    "monolog/monolog": "^2.0",
    "ext-redis": "*",
    "php": ">=5.4.0",
    },

配置文件

return array(
    /**
     * 当前项目的唯一标识
     * 用来区分日志系统中不同项目的日志
     * 用来创建es索引,不能出现大写字母
     */
    'projectName' => 'user_center',

    /**
     * redis缓存配置
     * 日志传送的redis数据库
     */
    'redisConfig' => array(
        'host' => '192.168.107.107',
        'port' => 6379,
        'select' => 0,
    ),

    /**
     * 短信报警配置
     * 每小时报警次数是alertCondition的整数倍会发送报警短信
     * 每小时至多发送5条
     */
    'smsConfig' => array(
        // 报警短信接收号码必须配置
        'phones' => array(
        ),
        // 发送条件必须为正整数,默认为10,每小时发生错误的数量是报警条件的整数倍时,发送一次报警短信
        'alertCondition' => 10,
    ),

    /**
     * 日志文件目录,使用绝对路径,默认tmp目录
     */
    'logDir' => '/tmp',
);

使用方法

1.日志分类

扩展

1.BuildParams,添加参数

// 应用开始
'app_begin'    => [
    'your_path\BuildParams',
],

class BuildParams
{
    /**
     * 将参数添加到日志中
     */
    public function run() {
        $params = Request::instance()->param();
        Logger::getLogger()->system()->getUseAge()->pushProcessor(function ($record) use ($params) {
            $record['extra']['params'] = json_encode($params, JSON_UNESCAPED_UNICODE);
            return $record;
        });
    }

}

2.buildResponse,添加返回的数据

// 应用结束(TP项目)
'app_end'      => [
    'your_path\BuildResponse',
],

/**
 * BuildResponse.php
 * 将返回数据添加到日志中
 * @param Response $response
 */
public function run(Response $response) {
    $response = $response->getData();
    // 本次访问返回的数据
    $response = is_array($response) ? json_encode($response, JSON_UNESCAPED_UNICODE) : $response;
    // 本次访问运行的时间
    $runTime = microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'];
    if($runTime > 1){ // 时间可根据项目自行配置
        Logger::getLogger()->common()->warn('本次运行时间过长', array('runTime' => $runTime.' s'));
    }
    Logger::getLogger()->system()->getUseAge()->pushProcessor(function ($record) use ($response, $runTime) {
        $record['extra']['runTime'] = $runTime.' s';
        $record['extra']['response'] =  $response;
        return $record;
    });
    Logger::getLogger()->system()->info('success');
}

3.CacheException,捕获系统异常,报警依赖此项

ThinkPHP 异常处理

Laravel 错误处理

/**
 - 系统级别异常处理文件
 - config配置文件中 'exception_handle' => '\\app\\common\\exception\\Http',定义
 - Class Http
 - @package app\common\exception
 */
class Http extends Handle
{
    public function render(Exception $e)
    {
        //TODO::开发者对异常的操作
        //可以在此交由系统处理
        Logger::getLogger()->critical('file:'.$e->getFile().' line:'. $e->getLine().' msg:'.$e->getMessage());
        return parent::render($e);
    }
}

错误级别定义


All versions of logger with dependencies

PHP Build Version
Package Version
Requires monolog/monolog Version ^2.0
php Version >=5.6
ext-redis Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package fengxinyhyl/logger contains the following files

Loading the files please wait ....