2017 © Pedro Peláez
 

library log

Yii Logging Library

image

yiisoft/log

Yii Logging Library

  • Thursday, August 2, 2018
  • by cebe
  • Repository
  • 7 Watchers
  • 7 Stars
  • 50 Installations
  • PHP
  • 4 Dependents
  • 1 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

, (*1)

Yii Logging Library


Latest Stable Version Total Downloads Build status Scrutinizer Code Quality Code Coverage Mutation testing badge static analysis type-coverage, (*2)

This package provides PSR-3 compatible logging library. It is used in Yii Framework but is usable separately., (*3)

The logger sends passes messages to multiple targets. Each target may filter messages by their severity levels and categories and then export them to some medium such as file, email or syslog., (*4)

Requirements

  • PHP 8.0 or higher.

Installation

The package could be installed with composer:, (*5)

composer require yiisoft/log --prefer-dist

General usage

Creating a logger:, (*6)


/** * List of class instances that extend the \Yiisoft\Log\Target abstract class. * * @var \Yiisoft\Log\Target[] $targets */ $logger = new \Yiisoft\Log\Logger($targets);

Writing logs:, (*7)

$logger->emergency('Emergency message', ['key' => 'value']);
$logger->alert('Alert message', ['key' => 'value']);
$logger->critical('Critical message', ['key' => 'value']);
$logger->warning('Warning message', ['key' => 'value']);
$logger->notice('Notice message', ['key' => 'value']);
$logger->info('Info message', ['key' => 'value']);
$logger->debug('Debug message', ['key' => 'value']);

Message Flushing and Exporting

Log messages are collected and stored in memory. To limit memory consumption, the logger will flush the recorded messages to the log targets each time a certain number of log messages accumulate. You can customize this number by calling the \Yiisoft\Log\Logger::setFlushInterval() method:, (*8)

$logger->setFlushInterval(100); // default is 1000

Each log target also collects and stores messages in memory. Message exporting in a target follows the same principle as in the logger. To change the number of stored messages, call the \Yiisoft\Log\Target::setExportInterval() method:, (*9)

$target->setExportInterval(100); // default is 1000

Note: All message flushing and exporting also occurs when the application ends., (*10)

Logging targets

This package contains two targets:, (*11)

  • Yiisoft\Log\PsrTarget - passes log messages to another PSR-3 compatible logger.
  • Yiisoft\Log\StreamTarget - writes log messages to the specified output stream.

Extra logging targets are implemented as separate packages:, (*12)

See Yii guide to logging for more info., (*13)

Testing

Unit testing

The package is tested with PHPUnit. To run tests:, (*14)

./vendor/bin/phpunit

Mutation testing

The package tests are checked with Infection mutation framework with Infection Static Analysis Plugin. To run it:, (*15)

./vendor/bin/roave-infection-static-analysis-plugin

Static analysis

The code is statically analyzed with Psalm. To run static analysis:, (*16)

./vendor/bin/psalm

License

The Yii Logging Library is free software. It is released under the terms of the BSD License. Please see LICENSE for more information., (*17)

Maintained by Yii Software., (*18)

Support the project

Open Collective, (*19)

Follow updates

Official website Twitter Telegram Facebook Slack, (*20)

The Versions

02/08 2018

dev-master

9999999-dev http://www.yiiframework.com/

Yii Logging Library

  Sources   Download

BSD-3-Clause

The Requires

 

by Paul Klimov

logger log framework yii