All Projects → yiisoft → log

yiisoft / log

Licence: BSD-3-Clause license
PSR-3 compatible logger

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to log

log
Aplus Framework Log Library
Stars: ✭ 14 (-56.25%)
Mutual labels:  log, logger
JJSwiftLog
Swift log library for all platform
Stars: ✭ 51 (+59.38%)
Mutual labels:  log, logger
ng-logger
Angular logger service
Stars: ✭ 65 (+103.13%)
Mutual labels:  log, logger
Monolog Bundle
Symfony Monolog Bundle
Stars: ✭ 2,532 (+7812.5%)
Mutual labels:  log, logger
guzzle-log-middleware
A Guzzle middleware to log request and responses automatically
Stars: ✭ 61 (+90.63%)
Mutual labels:  log, logger
Golog
A high-performant Logging Foundation for Go Applications. X3 faster than the rest leveled loggers.
Stars: ✭ 208 (+550%)
Mutual labels:  log, logger
GoogleCloudLogging
Swift (Darwin) library for logging application events in Google Cloud.
Stars: ✭ 24 (-25%)
Mutual labels:  log, logger
Logger
✔️ Simple, pretty and powerful logger for android
Stars: ✭ 13,093 (+40815.63%)
Mutual labels:  log, logger
clue
a extremely high performance log library for android. 高性能的Android日志库
Stars: ✭ 27 (-15.62%)
Mutual labels:  log, logger
sprout
Golang logging library supporting log retrieval.
Stars: ✭ 85 (+165.63%)
Mutual labels:  log, logger
Xlog
Android logger, pretty, powerful and flexible, log to everywhere, save to file, all you want is here.
Stars: ✭ 2,468 (+7612.5%)
Mutual labels:  log, logger
l
Cross-platform html/io [L]ogger with simple API.
Stars: ✭ 26 (-18.75%)
Mutual labels:  log, logger
Logcat
Android 日志打印框架,在手机上可以直接看到 Logcat 日志啦
Stars: ✭ 189 (+490.63%)
Mutual labels:  log, logger
datalogger
DataLogger foi projetado para ser uma biblioteca simples de log com suporte a vários providers.
Stars: ✭ 46 (+43.75%)
Mutual labels:  log, logger
Acho
The Hackable Log
Stars: ✭ 189 (+490.63%)
Mutual labels:  log, logger
LogDNA-Android-Client
Android client for LogDNA
Stars: ✭ 22 (-31.25%)
Mutual labels:  log, logger
Easy Log Handler
Human-friendly log files that make you more productive
Stars: ✭ 2,070 (+6368.75%)
Mutual labels:  log, logger
Lajax
🚀 lajax - 前端日志解决方案。
Stars: ✭ 181 (+465.63%)
Mutual labels:  log, logger
log-target-file
Yii Logging Library - File Target
Stars: ✭ 19 (-40.62%)
Mutual labels:  log, yii3
log
A simple to use log system, minimalist but with features for debugging and differentiation of messages
Stars: ✭ 21 (-34.37%)
Mutual labels:  log, logger

Yii Logging Library


Latest Stable Version Total Downloads Build status Scrutinizer Code Quality Code Coverage Mutation testing badge static analysis type-coverage

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

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.

Requirements

  • PHP 8.0 or higher.

Installation

The package could be installed with composer:

composer require yiisoft/log --prefer-dist

General usage

Creating a logger:

/**
 * 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:

$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:

$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:

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

Note: All message flushing and exporting also occurs when the application ends.

Logging targets

This package contains two targets:

  • 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:

See Yii guide to logging for more info.

Testing

Unit testing

The package is tested with PHPUnit. To run tests:

./vendor/bin/phpunit

Mutation testing

The package tests are checked with Infection mutation framework with Infection Static Analysis Plugin. To run it:

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

Static analysis

The code is statically analyzed with Psalm. To run static analysis:

./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.

Maintained by Yii Software.

Support the project

Open Collective

Follow updates

Official website Twitter Telegram Facebook Slack

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].