🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
[TOC] ## 安装 ``` composer require psr/log ``` ## 接口 <details> <summary>Psr\Log\LoggerInterface</summary> ``` interface LoggerInterface { /** * 系统无法使用。 * * @param string $message * @param array $context * @return void */ public function emergency($message, array $context = array()); /** * 必须立即采取行动。 * * 例如: 整个网站宕机了,数据库挂了,等等。 这应该 * 发送短信通知警告你. * * @param string $message * @param array $context * @return void */ public function alert($message, array $context = array()); /** * 临界条件。 * * 例如: 应用组件不可用,意外的异常。 * * @param string $message * @param array $context * @return void */ public function critical($message, array $context = array()); /** * 运行时错误不需要马上处理, * 但通常应该被记录和监控。 * * @param string $message * @param array $context * @return void */ public function error($message, array $context = array()); /** * 例外事件不是错误。 * * 例如: 使用过时的API,API使用不当,不合理的东西不一定是错误。 * * @param string $message * @param array $context * @return void */ public function warning($message, array $context = array()); /** * 正常但重要的事件. * * @param string $message * @param array $context * @return void */ public function notice($message, array $context = array()); /** * 有趣的事件. * * 例如: 用户登录,SQL日志。 * * @param string $message * @param array $context * @return void */ public function info($message, array $context = array()); /** * 详细的调试信息。 * * @param string $message * @param array $context * @return void */ public function debug($message, array $context = array()); /** * 可任意级别记录日志。 * * @param mixed $level * @param string $message * @param array $context * @return void */ public function log($level, $message, array $context = array()); } ``` </details> <br /> <details> <summary>Psr\Log\LoggerAwareInterface</summary> ``` <?php namespace Psr\Log; /** * logger-aware 定义实例 */ interface LoggerAwareInterface { /** * 设置一个日志记录实例 * * @param LoggerInterface $logger * @return void */ public function setLogger(LoggerInterface $logger); } ``` </details> <br /> <details> <summary>Psr\Log\LogLevel</summary> ``` <?php namespace Psr\Log; /** * 日志等级常量定义 */ class LogLevel { const EMERGENCY = 'emergency'; const ALERT = 'alert'; const CRITICAL = 'critical'; const ERROR = 'error'; const WARNING = 'warning'; const NOTICE = 'notice'; const INFO = 'info'; const DEBUG = 'debug'; } ``` </details> <br />