Robust, composite logger with filtering, formatting, and PSR-3 support

Overview

laminas-log

Build Status

πŸ‡·πŸ‡Ί Русским Π³Ρ€Π°ΠΆΠ΄Π°Π½Π°ΠΌ

ΠœΡ‹, участники Laminas, Ρ€ΠΎΠ΄ΠΈΠ»ΠΈΡΡŒ ΠΈ ΠΆΠΈΠ²Π΅ΠΌ Π² Ρ€Π°Π·Π½Ρ‹Ρ… странах. Π£ ΠΌΠ½ΠΎΠ³ΠΈΡ… ΠΈΠ· нас Π΅ΡΡ‚ΡŒ Π΄Ρ€ΡƒΠ·ΡŒΡ, родствСнники ΠΈ ΠΊΠΎΠ»Π»Π΅Π³ΠΈ ΠΊΠ°ΠΊ Π² России, Ρ‚Π°ΠΊ ΠΈ Π² Π£ΠΊΡ€Π°ΠΈΠ½Π΅. НСкоторыС ΠΈΠ· нас Ρ€ΠΎΠ΄ΠΈΠ»ΠΈΡΡŒ Π² России. НСкоторыС ΠΈΠ· нас ΠΆΠΈΠ²ΡƒΡ‚ Π² России. Π£ Π½Π΅ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Ρ… Π±Π°Π±ΡƒΡˆΠΊΠΈ ΠΈ Π΄Π΅Π΄ΡƒΡˆΠΊΠΈ ΡΡ€Π°ΠΆΠ°Π»ΠΈΡΡŒ с Ρ„Π°ΡˆΠΈΡΡ‚Π°ΠΌΠΈ Π²ΠΎ Π’Ρ‚ΠΎΡ€ΠΎΠΉ ΠΌΠΈΡ€ΠΎΠ²ΠΎΠΉ Π²ΠΎΠΉΠ½Π΅. Π—Π΄Π΅ΡΡŒ Π½ΠΈΠΊΡ‚ΠΎ Π½Π΅ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΈΠ²Π°Π΅Ρ‚ Ρ„Π°ΡˆΠΈΠ·ΠΌ.

Π£ ΠΎΠ΄Π½ΠΎΠ³ΠΎ ΠΈΠ· нас Π΅ΡΡ‚ΡŒ украинская родствСнница, которая спаслась ΠΈΠ· Π΄ΠΎΠΌΠ° вмСстС с сыном. ПоСзд задСрТался ΠΈΠ·-Π·Π° Π±ΠΎΠΌΠ±Π΅ΠΆΠΊΠΈ Π½Π° Π΄ΠΎΡ€ΠΎΠ³Π΅ Π²ΠΏΠ΅Ρ€Π΅Π΄ΠΈ. Π£ нас Π΅ΡΡ‚ΡŒ Π΄Ρ€ΡƒΠ·ΡŒΡ, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ прячутся Π² Π±ΠΎΠΌΠ±ΠΎΡƒΠ±Π΅ΠΆΠΈΡ‰Π°Ρ…. ΠœΡ‹ с Ρ‚Ρ€Π΅Π²ΠΎΠ³ΠΎΠΉ ΠΆΠ΄Π΅ΠΌ вСсточки ΠΎΡ‚ Π½ΠΈΡ… послС Π²ΠΎΠ·Π΄ΡƒΡˆΠ½Ρ‹Ρ… Π½Π°Π»Π΅Ρ‚ΠΎΠ², ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ бСспорядочно наносят ΡƒΠ΄Π°Ρ€Ρ‹ ΠΈ ΠΏΠΎΠΏΠ°Π΄Π°ΡŽΡ‚ ΠΏΠΎ Π±ΠΎΠ»ΡŒΠ½ΠΈΡ†Π°ΠΌ, школам, дСтским садам ΠΈ Π΄ΠΎΠΌΠ°ΠΌ. ΠœΡ‹ Π½Π΅ Π±Π΅Ρ€Π΅ΠΌ это ΠΈΠ· ΠΊΠ°ΠΊΠΈΡ…-Π»ΠΈΠ±ΠΎ БМИ. ΠœΡ‹ наблюдаСм это Π½Π°ΠΏΡ€ΡΠΌΡƒΡŽ.

Π’Ρ‹ довСряСтС Π½Π°ΠΌ достаточно, Ρ‡Ρ‚ΠΎΠ± ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ наши ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΡ‹, ΠΈ ΠΌΡ‹ просим вас Π΄ΠΎΠ²Π΅Ρ€ΠΈΡ‚ΡŒΡΡ Π½Π°ΠΌ вновь. ΠœΡ‹ нуТдаСмся Π² ΠΏΠΎΠΌΠΎΡ‰ΠΈ. Π’Ρ‹Ρ…ΠΎΠ΄ΠΈΡ‚Π΅ ΠΈ протСстуйтС ΠΏΡ€ΠΎΡ‚ΠΈΠ² этой бСсполСзной Π²ΠΎΠΉΠ½Ρ‹. ΠžΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚Π΅ ΠΊΡ€ΠΎΠ²ΠΎΠΏΡ€ΠΎΠ»ΠΈΡ‚ΠΈΠ΅. Π‘ΠΊΠ°ΠΆΠΈΡ‚Π΅ "НСт Π²ΠΎΠΉΠ½Π΅!"

πŸ‡ΊπŸ‡Έ To Citizens of Russia

We at Laminas come from all over the world. Many of us have friends, family and colleagues in both Russia and Ukraine. Some of us were born in Russia. Some of us currently live in Russia. Some have grandparents who fought Nazis in World War II. Nobody here supports fascism.

One team member has a Ukrainian relative who fled her home with her son. The train was delayed due to bombing on the road ahead. We have friends who are hiding in bomb shelters. We anxiously follow up on them after the air raids, which indiscriminately fire at hospitals, schools, kindergartens and houses. We're not taking this from any media. These are our actual experiences.

You trust us enough to use our software. We ask that you trust us to say the truth on this. We need your help. Go out and protest this unnecessary war. Stop the bloodshed. Say "stop the war!"


Security-Only Maintenance Mode

This package is considered feature-complete, and is now in security-only maintenance mode, following a decision by the Technical Steering Committee. If you have a security issue, please follow our security reporting guidelines. If you wish to take on the role of maintainer, please nominate yourself

Laminas\Log is a component for general purpose logging. It supports multiple log backends, formatting messages sent to the log, and filtering messages from being logged.

Installation

Run the following to install this library:

$ composer require laminas/laminas-log

Documentation

Browse the documentation online at https://docs.laminas.dev/laminas-log/

Support

Comments
  • Have LoggerServiceFactory inject writer and processor plugin managers

    Have LoggerServiceFactory inject writer and processor plugin managers

    | Q | A |-------------- | ------ | Documentation | no | Bugfix | yes | BC Break | no | New Feature | no

    Description

    The issue: LoggerServiceFactory does not inject the writer nor the processor plugin managers. But LoggerAbstractServiceFactory does. And I want to use the former with custom processors.

    I changed the inheritance so LoggerAbstractServiceFactory extends LoggerServiceFactory and moved some logic, so both inject the relevant plugin managers in the same way.

    I changed PsrLoggerAbstractAdapterFactory to compose LoggerAbstractServiceFactory, not inherit. It didn't make sense as the return types for __invoke were incompatible. So adding strict typing across much of the factories would be possible now

    Added unit tests for LoggerServiceFactory. All other unit tests still pass, and the factories can still be used in exactly the same way. Only difference is now LoggerServiceFactory injects the plugin managers.

    Typing only added to anything new to maintain BC

    I want to target the 2.15.x branch, as i see this as a bugfix - however, i am new to open source, and am open to guidance.

    Awaiting Maintainer Response Bug 
    opened by TotalWipeOut 18
  • Implement PSR-3 for LoggerInterface

    Implement PSR-3 for LoggerInterface

    Hey,

    is there any information or discussion about implementing the PSR-3 standard for Logger (https://github.com/php-fig/log). We often have this problem (like using also Monolog Logger).

    If not we will laminas-log and replace it with another framework.

    Best regards, David

    Question 
    opened by panvid 9
  • registerErrorHandler won't work unless you disable convertWriteErrorsToExceptions on the writer

    registerErrorHandler won't work unless you disable convertWriteErrorsToExceptions on the writer

    Bug Report

    | Q | A |------------ | ------ | Version(s) | 2.12

    Summary

    Laminas\Log\Logger::registerErrorHandler wraps around set_error_handler. By default AbstractWriter starts Laminas\Stdlib\ErrorHandler before writing and stops it after. ErrorHandler's stop function in turn calls restore_error_handler. In practice this means that a very basic setup with a simple stream writer would not write any errors after the first one, since php error handler gets restored on the first write.

    User can avoid this if he sets convertWriteErrorsToExceptions to false on the writer:

    $writer->setConvertWriteErrorsToExceptions(false)
    

    But this requires the user to first face this bug.

    This bug is present since at least Zend 2.

    Current behavior

    Only one error gets written by the writer. After that Laminas\Log php error handler gets removed.

    How to reproduce

    Very basic one stream writer example would already suffer from this bug:

    $logger = new Laminas\Log\Logger;
    $writer = new Laminas\Log\Writer\Stream('/test.log');
    
    $logger->addWriter($writer);
    Laminas\Log\Logger::registerErrorHandler($logger);
    
    $writer->setConvertWriteErrorsToExceptions(false);
    
    trigger_error('test1');
    trigger_error('test2');
    
    

    Expected behavior

    Ideally the ErrorHandler class should not call restore_error_handler and somehow remove only himself from the error handlers list. Unfortunately PHP does not have an API to do this. The easiest fix is probably setting convertWriteErrorsToExceptions to false by default, but this brings back the reason why it converts errors to exceptions: now user has no way of knowing that his logging has failed.

    Invalid 
    opened by sg2002 7
  • Exception logging in MariaDb

    Exception logging in MariaDb

    Bug Report

    If I try to log something using Laminas library (embedded in Omeka S software), I end up with an exception (Omeka store logs in a database table).

    | Q | A |------------ | ------ | Laminas Version(s) | 2.6.0 | Maria db version| 10.5.9 | Omeka S version|3.1.1

    Summary

    Current behavior

    An exception is thrown

    [Fri Apr 08 13:12:40.596256 2022] [php7:notice] [pid 17] [client 193.48.70.142:58478] PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '"log" ("created","severity","message","owner_id","context") VALUES ('2022-04-...' at line 1 in /var/www/html/vendor/laminas/laminas-db/src/Adapter/Driver/Pdo/Statement.php:238
    Stack trace:
    #0 /var/www/html/vendor/laminas/laminas-db/src/Adapter/Driver/Pdo/Statement.php(238): PDOStatement->execute()
    #1 /var/www/html/vendor/laminas/laminas-log/src/Writer/Db.php(128): Laminas\\Db\\Adapter\\Driver\\Pdo\\Statement->execute(Array)
    #2 /var/www/html/vendor/laminas/laminas-log/src/Writer/AbstractWriter.php(282): Laminas\\Log\\Writer\\Db->doWrite(Array)
    #3 /var/www/html/vendor/laminas/laminas-log/src/Logger.php(459): Laminas\\Log\\Writer\\AbstractWriter->write(Array)
    #4 /var/www/html/vendor/laminas/laminas-log/src/Logger.php(502): Laminas\\Log\\Logger->log(3, 'Exception: Noid...', Array)
    #5 /var/www/html/application/src/Mvc/ExceptionListener.php(54): Laminas\\Log\\Logger->err('Exception: Noid...')
    #6 /var/www/html/vendor/laminas/laminas-eventmanager/src/EventManager.php(321): Omeka\\Mvc\\ExceptionListener->handleException(Object(Laminas\\Mvc\\MvcEvent))
    #7 /var/www/html/vendor/laminas/laminas-eventmanager/src/EventManager.php(170): Laminas\\EventManager\\EventManager->triggerListeners(Object(Laminas\\Mvc\\MvcEvent))
    #8 /var/www/html/vendor/laminas/laminas-mvc/src/DispatchListener.php(153): Laminas\\EventManager\\EventManager->triggerEvent(Object(Laminas\\Mvc\\MvcEvent))
    #9 /var/www/html/vendor/laminas/laminas-eventmanager/src/EventManager.php(321): Laminas\\Mvc\\DispatchListener->onDispatch(Object(Laminas\\Mvc\\MvcEvent))
    #10 /var/www/html/vendor/laminas/laminas-eventmanager/src/EventManager.php(178): Laminas\\EventManager\\EventManager->triggerListeners(Object(Laminas\\Mvc\\MvcEvent), Object(Closure))
    #11 /var/www/html/vendor/laminas/laminas-mvc/src/Application.php(331): Laminas\\EventManager\\EventManager->triggerEventUntil(Object(Closure), Object(Laminas\\Mvc\\MvcEvent))
    #12 /var/www/html/index.php(21): Laminas\\Mvc\\Application->run()
    #13 {main}
    

    How to reproduce

    Log any message.

    Expected behavior

    Log should be stored in database without any issue.

    Identified causes and Workaround

    This issue is caused because Mariadb only accepts backtick ` around identifiers by default. Double quote " needs to be specified in SQL_MODE (source) to be accepted. A way (the only way I found, actually) to get rid of this issue is to set SQL_MODE to ANSI_QUOTES.

    Bug 
    opened by olivierbicler 4
  • Error on build deploy for docs: The unauthenticated git protocol on port 9418 is no longer supported.

    Error on build deploy for docs: The unauthenticated git protocol on port 9418 is no longer supported.

    https://github.com/laminas/laminas-log/runs/6223336132?check_suite_focus=true#step:3:11

    @weierophinney or @Xerkus can you help here? Thanks in advance!

    Bug Documentation 
    opened by froschdesign 4
  • Not able to udpate laminas-log to version 2.13.1

    Not able to udpate laminas-log to version 2.13.1

    Hi Team,

    not able to update laminas-log version from 2.12.1 to 2.13.1.

    Current version is 2.12.1

    and while update using composer I am seeing message "nothing to install or update"

    My Current php version 7.4.18

    Could you please let know If I am doing anything wrong ?

    BC Break Invalid 
    opened by dhananjay5358 4
  • Fatal error: nesting level in zend-log/src/LoggerAbstractServiceFactory.php on line 85

    Fatal error: nesting level in zend-log/src/LoggerAbstractServiceFactory.php on line 85

    Fatal error: Maximum function nesting level of '100' reached, aborting! in ../library/zendframework/zend-log/src/LoggerAbstractServiceFactory.php on line 85

    Problem resolve when we put a "Config" on $services->has('config') line 91...


    Originally posted by @nsantosMyt at https://github.com/zendframework/zend-log/issues/34

    opened by weierophinney 4
  • Simple formatter broken with non-array value extra array key in PHP > 8

    Simple formatter broken with non-array value extra array key in PHP > 8

    Bug Report

    | Q | A |------------ | ------ | Version(s) | 2.15.1

    Summary

    Simple formatter broken with non-array value extra array key when using PHP version 8++.

    How to reproduce

            $date   = new DateTime('2012-08-28T18:15:00Z');
            $fields = [
                'timestamp'    => $date,
                'message'      => 'foo',
                'priority'     => 42,
                'priorityName' => 'bar',
                'extra'        => null,
            ];
            $formatter = new Simple();
            echo $formatter->format($fields);
            // Throws error: TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given
    
            $date   = new DateTime('2012-08-28T18:15:00Z');
            $fields = [
                'timestamp'    => $date,
                'message'      => 'foo',
                'priority'     => 42,
                'priorityName' => 'bar',
                'extra'        => '',
            ];
            $formatter = new Simple();
    
            echo $formatter->format($fields);
            // Throws error: TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given
    

    Expected behavior

            $date   = new DateTime('2012-08-28T18:15:00Z');
            $fields = [
                'timestamp'    => $date,
                'message'      => 'foo',
                'priority'     => 42,
                'priorityName' => 'bar',
                'extra'        => null,
            ];
            $formatter = new Simple();
            echo $formatter->format($fields);
            // Output: 2012-08-28T18:15:00+00:00 bar (42): foo
    
            $date   = new DateTime('2012-08-28T18:15:00Z');
            $fields = [
                'timestamp'    => $date,
                'message'      => 'foo',
                'priority'     => 42,
                'priorityName' => 'bar',
                'extra'        => '',
            ];
    
            $formatter = new Simple();
            echo $formatter->format($fields);
            // Output: 2012-08-28T18:15:00+00:00 bar (42): foo
    
    Bug 
    opened by misterabdul 3
  • Cannot install package on a clean mezzio skeleton project

    Cannot install package on a clean mezzio skeleton project

    Bug Report

    | Q | A |------------ | ------ | PHP | 8.1 | Composer | 2.4.4

    Summary

    Cannot install package on a clean mezzio skeleton installation laminas-log

    Current behavior

    composer shows "Your requirements could not be resolved to an installable set of packages." after command composer require laminas/laminas-log

    How to reproduce

    create a fresh mezzio skeleton installation then run composer require laminas/laminas-log

    Expected behavior

    laminas-log installed

    Bug 
    opened by dansol 2
  • Adding details about the second parameter for `Laminas\Log\Formatter\Simple`, the `DateTime` object format

    Adding details about the second parameter for `Laminas\Log\Formatter\Simple`, the `DateTime` object format

    | Q | A |-------------- | ------ | Documentation | yes | Bugfix | no | BC Break | no | New Feature | no | RFC | no | QA | no

    Description

    Adding details about the second parameter for Laminas\Log\Formatter\Simple, the DateTime object format.

    Documentation Enhancement 
    opened by galvao 2
  • Apply PHP 7.4 syntax

    Apply PHP 7.4 syntax

    | Q | A |-------------- | ------ | QA | yes

    Description

    Updated to use up to php 7.4 syntax and typed property (for private modifier only to keep BC) as now requirement is minimal php 7.4

    opened by samsonasik 2
Releases(2.16.1)
Owner
Laminas Project
Laminas components and MVC.
Laminas Project
Slim-Logger - A stand-alone logger class for use with the Slim Framework

Slim-Logger - A stand-alone logger class for use with the Slim Framework

Josh Lockhart 41 Mar 12, 2022
Test Doubles for the PSR-3 Logger Interface

PSR Log Test Doubles Test Doubles for the PSR-3 Logger Interface Motivation In PHP world, most people create Test Doubles via PHPUnits mocking framewo

Jeroen De Dauw 2 Oct 7, 2022
Allows you to process logs using any PSR-3 compatible logger such as Monolog

Yii 2 PSR Log Target Allows you to process logs using any PSR-3 compatible logger such as Monolog

Alexander Makarov 67 Dec 14, 2022
123Solar is a set of PHP/JS files that make a web logger to monitor your photovoltaic inverter(s)

123Solar is a set of PHP/JS files that make a web logger to monitor your photovoltaic inverter(s). It just need a web server and PHP, no databases are even needed. The philosophy is: To keep it simple, fast, with a low foot print to run on cheap and low powered devices.

null 30 Jan 6, 2023
A simple database logger for all outgoing emails sent by Laravel website.

Laravel Email Database Log A simple database logger for all outgoing emails sent by Laravel website.

Shvets Group 136 Jan 4, 2023
Simple PHP Logger. Composer package

Basic PHP Logger ?? Simple logger. Composer package.

null 1 Jan 28, 2022
temperature-pi: a simple Raspberry Pi based temperature logger using a DS18B20 1-Wire digital temperature sensor, & a local sqlite database

temperature-pi temperature-pi is a simple Raspberry Pi based temperature logger using a DS18B20 1-Wire digital temperature sensor, & a local sqlite da

Ronan Guilloux 23 Dec 27, 2020
πŸ“‘ Laravel HTTP Logger

Logging incoming HTTP requests

The Dragon Code 28 Nov 29, 2022
ChromePhp - a PHP library for the Chrome Logger Google Chrome extension

ChromePhp - a PHP library for the Chrome Logger Google Chrome extension

Craig Campbell 1.4k Dec 30, 2022
Monolog logging support for Slim Framework

Monolog Logging for Slim Framework This repository adds support for logging to Monolog to the Slim Framework. Installation MonologWriter takes an arra

null 113 Dec 18, 2022
Capture and monitor detailed error logs with nice dashboard and UI

Capture and monitor detailed error logs with nice dashboard and UI Requirements Check Laravel 6 requirements Check Laravel 7 requirements Installation

Bugphix 107 Dec 12, 2022
Sends your logs to files, sockets, inboxes, databases and various web services

Monolog - Logging for PHP Monolog sends your logs to files, sockets, inboxes, databases and various web services. See the complete list of handlers be

Jordi Boggiano 20.1k Jan 8, 2023
PHP logging library that is highly extendable and simple to use.

Analog - Minimal PHP logging library Copyright: (c) 2012-Present Johnny Broadway License: MIT A minimal PHP logging package based on the idea of using

Aband*nthecar 331 Dec 21, 2022
Flexible and rock solid audit log tracking for CakePHP 3

AuditStash Plugin For CakePHP This plugin implements an "audit trail" for any of your Table classes in your application, that is, the ability of recor

JosΓ© Lorenzo RodrΓ­guez 68 Dec 15, 2022
DatabaseLog CakePHP plugin to log into DB instead of files. Better to filter and search.

CakePHP DatabaseLog Plugin DatabaseLog engine for CakePHP applications. This branch is for CakePHP 4.0+. See version map for details. Features Easy se

Mark Sch. 41 Jul 29, 2022
Paste, share and analyse Minecraft server logs

mclo.gs Paste, share & analyse your Minecraft server logs About The project mclo.gs was created in 2017 by the Aternos team after more than 4 years of

Aternos 99 Jan 3, 2023
Keep your laravel logs small and tidy.

Logs can get quite out of hand. This package helps save server space and keep your Laravel log files small.

Accent Interactive 73 Nov 14, 2022
Log Laravel application request and response with a unique ID for easy debugging

Flexible and extendable logging of Laravel application request and responses Zero configuration logging of Requests and Responses to database or custo

Bilfeldt 37 Nov 6, 2022
A simple and beautiful laravel log reader

Laravel Log Reader A simple and beautiful laravel log reader Documentation Get full documentation of Laravel Log Reader Other Packages Laravel H - A h

Md.Harun-Ur-Rashid 356 Dec 30, 2022