log

  • 所有者: php-fig/log
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

PSR Log

This repository holds all interfaces/classes/traits related to
PSR-3.

Note that this is not a logger of its own. It is merely an interface that
describes a logger. See the specification for more details.

Installation

composer require psr/log

Usage

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

<?php

use Psr\Log\LoggerInterface;

class Foo
{
    private $logger;

    public function __construct(LoggerInterface $logger = null)
    {
        $this->logger = $logger;
    }

    public function doSomething()
    {
        if ($this->logger) {
            $this->logger->info('Doing work');
        }
           
        try {
            $this->doSomethingElse();
        } catch (Exception $exception) {
            $this->logger->error('Oh no!', array('exception' => $exception));
        }

        // do something useful
    }
}

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.

主要指標

概覽
名稱與所有者php-fig/log
主編程語言PHP
編程語言PHP (語言數: 1)
平台
許可證MIT License
所有者活动
創建於2012-11-30 09:49:24
推送於2024-09-11 13:21:12
最后一次提交2024-09-11 15:17:53
發布數12
最新版本名稱3.0.2 (發布於 )
第一版名稱1.0.0 (發布於 )
用户参与
星數10.4k
關注者數63
派生數182
提交數97
已啟用問題?
問題數0
打開的問題數0
拉請求數36
打開的拉請求數1
關閉的拉請求數34
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?