定制 dadapas/log 二次开发

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

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

dadapas/log

Composer 安装命令:

composer require dadapas/log

包简介

Common libraries implementating psr-3 logging interface

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

This repository implements interfaces related to PSR-3.

Installation

composer require dadapas/log

Usage

If you need a logger, you can use the interface like this:

<?php

use Dadapas\Log\{FileSystemAdapter, Log as Logger};

$localAdapter = new \League\Flysystem\Local\LocalFilesystemAdapter(
    // Determine log directory
    __DIR__.'/path/to/logs'
);

// The FilesystemOperator
$filesystem = new \League\Flysystem\Filesystem($localAdapter);
$filesysAdapter = new FileSystemAdapter($filesystem);

$logger = new Logger();
$logger->setAdapter($filesysAdapter);

To send a logger to an email will be like:

// ...
use Dadapas\Log\PHPMailerAdapter;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;

$mail = new PHPMailer(true);

// $mail->SMTPDebug  = SMTP::DEBUG_SERVER;
// $mail->isSMTP();
// $mail->Host       = 'smtp.example.com';
// $mail->SMTPAuth   = true;

// ...
$adapter = new PHPMailerAdapter($mail);

// ...
$logger->setAdapter($adapter);

Make a log to the file

// ...
try {
    throw new Exception("An exception has been thrown.");
} catch (Exception $e) {

    // Log to the the error message to file
    $logger->error($e->getMessage(), $e->getTrace());

} catch (\PHPMailer\PHPMailer\Exception $e) {

    echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}

You can then pick one of the implementations of the interface to get a logger.

If you want to implement the interface, you can require this package and implement Psr\Log\LoggerInterface in your code. Please read the specification text for details.

Test

For making a test just

composer test

License

The licence is MIT for more details click here

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-06-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固