定制 logvice/phplogger 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

logvice/phplogger

Composer 安装命令:

composer require logvice/phplogger

包简介

Sends your logs to LogVice.com web services or your personal LogVice installation or to a local file.

README 文档

README

Build Status Coverage Status Total Downloads Software License

LogVice\PHPLogger sends your logs to LogVice.com service or to your own LogVice platform installation. This library implements the PSR-3 standards.

Installation

Install the latest version

composer require logvice/phplogger

Basic Usage

<?php

use LogVice\PHPLogger\Logger;
use LogVice\PHPLogger\Config;
use LogVice\PHPLogger\Output\TCPOutput;
use LogVice\PHPLogger\Output\UDPOutput;

// create a config instance
$config = new Config();
$config->setAppKey('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
$config->setEnvironment('dev');
$config->setChannel('php');
$config->activateBacktrace();
$config->setOutputHandlers([
    new TCPOutput('127.0.0.1', '8080'),
    new UDPOutput('127.0.0.1', '514'),
]);
$config->setLogLevel(Logger::DEBUG);

// create a log instance
$log = new Logger($config);

// add records to the log
$log->debug('foo');
$log->info('bar');
$log->notice('foo');
$log->warning('bar');
$log->error('foo');
$log->critical('bar');
$log->alert('foo');
$log->emergency('bar');
$log->log(Logger::ERROR, 'foo');

Register Error, Exception and Shutdown handlers

set_error_handler(function ($errno, $errstr, $errfile, $errline) {
    // create a config instance
    $config = new LogVice\PHPLogger\Config();
    $config->setAppKey('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
    $config->setEnvironment('dev');
    $config->setChannel('php');
    $config->setOutputHandlers([
        new LogVice\PHPLogger\Output\TCPOutput('127.0.0.1', '8080'),
        new LogVice\PHPLogger\Output\UDPOutput('127.0.0.1', '514'),
        new LogVice\PHPLogger\Output\FileOutput('path/to/logs', 'file-name', true)
    ]);
    $config->setLogLevel(Logger::ERROR);

    // create a log instance
    $logger = new LogVice\PHPLogger\Logger($config);

    $logger->handleError($errno, $errstr, $errfile, $errline);
});

set_exception_handler(function ($exception) {
    // create a config instance
    $config = new LogVice\PHPLogger\Config();
    $config->setAppKey('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
    $config->setEnvironment('dev');
    $config->setChannel('php');
    $config->setOutputHandlers([
        new LogVice\PHPLogger\Output\TCPOutput('127.0.0.1', '8080'),
        new LogVice\PHPLogger\Output\UDPOutput('127.0.0.1', '514'),
        new LogVice\PHPLogger\Output\FileOutput('path/to/logs', 'file-name', true)
    ]);
    $config->setLogLevel(Logger::ERROR);

    // create a log instance
    $logger = new LogVice\PHPLogger\Logger($config);

    $logger->handleException($exception);
});

register_shutdown_function(function () {
    // create a config instance
    $config = new LogVice\PHPLogger\Config();
    $config->setAppKey('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
    $config->setEnvironment('dev');
    $config->setChannel('php');
    $config->setOutputHandlers([
        new LogVice\PHPLogger\Output\TCPOutput('127.0.0.1', '8080'),
        new LogVice\PHPLogger\Output\UDPOutput('127.0.0.1', '514'),
        new LogVice\PHPLogger\Output\FileOutput('path/to/logs', 'file-name', true)
    ]);
    $config->setLogLevel(Logger::ERROR);

    // create a log instance
    $logger = new LogVice\PHPLogger\Logger($config);

    $logger->handleShutdownError();
});

About

Requirements

  • PHPLogger works with PHP 5.4 or above..

Submitting bugs and feature requests

Bugs and feature request use GitHub

Author

Alban Kora - ankdeveloper@gmail.com - http://twitter.com/albankora

License

PHPLogger is licensed under the MIT License - see the LICENSE file for details

统计信息

  • 总下载量: 32
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-11-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固