Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on May 17, 2024 via composer

psr/log 3.0.0

Common interface for logging libraries
Package summary
Share
0
issues
1
license
1
MIT
Package created
21 Dec 2012
Version published
14 Jul 2021
Maintainers
3
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
psr/log@3.0.0
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of psr/log 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does psr/log do?

The PSR Log package offers a common interface for logging libraries in PHP. However, it's important to note that PSR/log is not a logger by itself, but it defines a standardized interface that describes how a logger should behave. This interoperability allows developers to build onto or interchangeably utilize various logging libraries that comply with the PSR-3 standard without changing their core code.

How do you use psr/log?

Using the PSR Log package in your PHP application is straightforward and involves a few steps. First, install the package into your project with Composer using the following command:

composer require psr/log

Then, use the Psr\Log\LoggerInterface in your class and inject it in the constructor, saving it as a private property. This logger can then be used within your class to log information and errors. Here's an example of how you can achieve 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
    }
}

To get a logger, you can choose one of the implementations of the LoggerInterface.

Where are the psr/log docs?

The documentation for PSR/log can be found in the form of a specification text directly on the official PHP Standards Recommendation (PSR) GitHub page in the PSR-3 logger interface section. You can find it at this URL: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md. This contains all the details required to implement the PSR\Log\LoggerInterface correctly.