定制 morningtrain/wp-logger 二次开发

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

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

morningtrain/wp-logger

最新稳定版本:v0.1.2

Composer 安装命令:

composer require morningtrain/wp-logger

包简介

Logger interface

README 文档

README

Make it easier to handle different levels of log.

Table of Contents

Introduction

Make it easier to handle different levels of log.

Getting Started

To get started install the package as described below in Installation.

To use the tool have a look at Usage

Installation

Install with composer

composer require morningtrain/wp-logger

Dependencies

Usage

Initializing package

First of all, to get \Morningtrain\WP\Logger\Loggers\DatabaseLogger to work, the migration needs to be run. This is done be running the following method:

\Morningtrain\WP\Logger\Logger::initializeMigration()

Initialize \Morningtrain\WP\Logger\Logger with a slug and an array of the loggers that needs to be registered.
For each logger, there is some levels, that can be registered for the specific logger.

\Morningtrain\WP\Logger\Logger::registerLoggers(
    'logger', 
    [
        // Loggers
    ]
);

Loggers

Each logger has the following methods, to register what level(s) that is needed:

  • ->registerLevel($level)
  • ->registerLevels([$level])
  • ->registerAllLevels()
Database Logger

Make it possible to save logs to the database.
Class: \Morningtrain\WP\Logger\Loggers\DatabaseLogger

\Morningtrain\WP\Logger\Logger::databaseLogger()
File Logger

Make it possible to save logs to a file.
Class: \Morningtrain\WP\Logger\Loggers\FileLogger Parameters in callback:

  • string $filename
\Morningtrain\WP\Logger\Logger::fileLogger($filename)
Mail Logger

Make it possible to send logs to multiple emails.
Class: \Morningtrain\WP\Logger\Loggers\MailLogger Parameters in callback:

  • array $emails
\Morningtrain\WP\Logger\Logger::mailLogger($emails)
Ray Logger

Make it possible to send logs to a Ray client.
Class: \Morningtrain\WP\Logger\Loggers\RayLogger Parameters in callback:

  • bool $backtrace // Optional. If true, it will add backtrace
\Morningtrain\WP\Logger\Logger::rayLogger()

Levels

\Psr\Log\LogLevel::EMERGENCY
\Psr\Log\LogLevel::ALERT
\Psr\Log\LogLevel::CRITICAL
\Psr\Log\LogLevel::ERROR
\Psr\Log\LogLevel::WARNING
\Psr\Log\LogLevel::NOTICE
\Psr\Log\LogLevel::INFO
\Psr\Log\LogLevel::DEBUG

Use package

To get the Logger, that has been registered, the method \Morningtrain\WP\Logger\Logger::getLogger($slug), where the slug is needed.
When the logger is collected, there is a method, for each level, that can be call:

\Morningtrain\WP\Logger\Logger::getLogger('logger')
    ->emergency()
    ->alert()
    ->critical()
    ->error()
    ->warning()
    ->notice()
    ->info()
    ->debug()

Each of these methods that:

  • string $message
  • array $context // Optional

Contributing

Thank you for your interest in contributing to the project.

Bug Report

If you found a bug, we encourage you to make a pull request.

To add a bug report, create a new issue. Please remember to add a telling title, detailed description and how to reproduce the problem.

Support Questions

We do not provide support for this package.

Pull Requests

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Contributors

License

The MIT License (MIT). Please see License File for more information.

Developed by

Morningtrain logo

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-05-03