micronext/php-std-logger

简单的PHP日志库,根据LogLevel将数据输出到控制台的标准输出stdout或stderr。实现了PSR-3定义的接口。

1.0.4 2018-11-02 09:45 UTC

This package is auto-updated.

Last update: 2024-09-29 05:28:02 UTC


README

目的:根据LogLevel将应用日志输出到stdout/stderr,并按用户定义的格式输出。运行时

当然,对于撒旦的狂风暴雨,也是一样 😈

动机:这可能会对喜欢🐳 Docker的粉丝非常有帮助。

设计得尽可能简单,遵循php-fig PSR和编码风格工具。

⚠️ 注意!目前只适用于PHP_CLI模式!

小巧且以简单为第一要务的PHP日志库,根据LogLevel将数据输出到控制台的标准输出stdout/stderr

实现了PSR-3定义的接口。

安装

composer require micronext/php-std-logger

开发

克隆此仓库

git clone https://github.com/micronext/php-std-logger
cd php-std-logger
composer install

用法

<?php

namespace YourAmazingApp;

use Psr\Log\LogLevel;
use MicroNext\StdOut\Logger;

$logger = new Logger;

$logger->emergency("emergency test");
$logger->alert("alert test");
$logger->critical("critical test");
$logger->error("error test");
$logger->warning("warning test");
$logger->notice("notice test");
$logger->info("info test");
$logger->debug("debug test");

// Also, you can call ->log() directly:
$logger->log(LogLevel::NOTICE, "notice throught log test";
$logger->log(null, "log test");

目前将标准输出std output分离到2个目标

LogLevel定义 @ PSR-3

stderr << log
when "LogLevel"
     ::EMERGENCY // System is unusable.
     ::ALERT // Action must be taken immediately.
     ::CRITICAL  // Critical conditions.
     ::ERROR // Runtime errors that do not require immediate action but should typically be logged and monitored.

stdout << log
when LogLevel
     ::WARNING // Exceptional occurrences that are not errors.
     ::NOTICE // Normal but significant events.
     ::INFO // Interesting events.
     ::DEBUG // Detailed debug information.

MIT许可证

Copyright 2018 (c) MicroNext

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

2018 © MicroNext (代表Yevhenii Ivanets)