定制 elephox/logging 二次开发

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

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

elephox/logging

Composer 安装命令:

composer require elephox/logging

包简介

Elephox Logging library.

README 文档

README

This module is used by Elephox to log information to one or more destinations (sinks).

Example

use Elephox\Logging\StandardSink;
use Elephox\Logging\SingleSinkLogger;
use Elephox\Logging\Contract\Sink;
use Elephox\Logging\LogLevel;

// create a logger with only one sink, a sink which logs to STDOUT and STDERR
$logger = new SingleSinkLogger(new StandardSink());

$logger->info('Hello world!'); // Prints to STDOUT: Hello world!
$logger->warning('This is a warning!'); // Prints to STDERR: This is a warning!

// You can also log meta data:
$logger->info('Hello world!', ['foo' => 'bar']);

// You can implement your own sink:
class MySink implements Sink
{
    public function write(string $message, LogLevel $level, array $metaData): void
    {
        $this->myThirdPartyLoggingService->log($message, $level->value, $metaData);
    }
}

$mySinkLogger = new SingleSinkLogger(new MySink());
$mySinkLogger->alert("This is an alert!");

You can also wrap sinks in decorator sinks (classes implementing SinkProxy):

use Elephox\Logging\SimpleFormatColorSink;
use Elephox\Logging\EnhancedMessageSink;

$standardSink = new StandardSink();
$formattedSink = new SimpleFormatColorSink($standardSink);

$formattedSink->write(LogLevel::INFO, '<blue>Hello</blue> <green>world</green>!', []);
// Prints a blue "Hello" and a green "world" to STDOUT

$enhancedSink = new EnhancedMessageSink($formattedSink);
$enhancedSink->write(LogLevel::INFO, '<blue>Hello</blue> <green>world</green>!', []);
// Prints a blue "Hello" and a green "world" to STDOUT, with a timestamp and a log level

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-11-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固