Monolog logging support for Slim Framework

Related tags

Logging Slim-Monolog
Overview

Monolog Logging for Slim Framework

This repository adds support for logging to Monolog to the Slim Framework.

Installation

MonologWriter takes an array of handlers, an array of processors and a logger name.

$logger = new \Flynsarmy\SlimMonolog\Log\MonologWriter(array(
    'handlers' => array(
        new \Monolog\Handler\StreamHandler('./logs/'.date('Y-m-d').'.log'),
    ),
));

$app = new \Slim\Slim(array(
    'log.writer' => $logger,
));

This example assumes you are autoloading dependencies using Composer. If you are not using Composer, you must manually require the log writer class before instantiating it.

License

The Slim-Monolog is released under the MIT public license.

Comments
  • Undefined class constants

    Undefined class constants

    Hi,

    I'm running Slim 2.2.0 and now encounter this error when declaring a new MonologWriter:

    Fatal error:  Undefined class constant 'Slim\Log::EMERGENCY'
    

    I get this error for all the new log levels added as part of: 00c4e3b872fbb2250c97bf7fefad326949902686

    If I revert the changes everything works again.

    opened by fenfe1 4
  • Monolog throws error because of constructor

    Monolog throws error because of constructor

    Monolog, as of 1.15.0, tries to create a dir on every log action and raises an exception: https://github.com/Seldaek/monolog/blob/6dd76b944d42d7b27bb3d09cd0f6fa88a80817f5/src/Monolog/Handler/StreamHandler.php#L51

    Slim-Monolog creates an unused monolog instance with an invalid log dir in its constructor: https://github.com/Flynsarmy/Slim-Monolog/blob/master/Log/MonologWriter.php#L108

    So applications with Monolog 1.15.0 and Slim-Monolog won't work now, I think.

    opened by bladi87 3
  • Hard coded path in library

    Hard coded path in library

    There is a hard-coded log location at line 110: https://github.com/Flynsarmy/Slim-Monolog/blob/master/Log/MonologWriter.php#L110

    new \Monolog\Handler\StreamHandler('./logs/'.date('y-m-d').'.log'),

    Since this hard coded location merges into the other locations array, it could easily cause a lot of problems in light-weight situations (like docker containers) which have virtually no disk space and do all their logging remotely. It also destroys one of the most valuable things about Monolog, that you have fine, granular control over where the logs go.

    It really should be 'handlers' => array(),

    Worse yet, because this merge is silent & undocumented, it took me about 3 hours to track this down as I didn't have a directory in "." called "logs".....

    opened by ckmaresca 2
  • adds get_resource method

    adds get_resource method

    adds a public method to retrieve the instanced \Monolog\Logger object, to access its methods.

    This is because, since Monolog#658, it's possible to configure the Logger instance to avoid using microsecond resolution timestamps, saving a few milliseconds on a middle sized PHP app.

    opened by ffflabs 1
  • Can you please create a tag for this repo

    Can you please create a tag for this repo

    So that I can atleast include a version number in my composer.json file rather then dev-master, because if a breaking change was to be made in dev-master, my code would be broken at that point.

    opened by silentworks 1
  • monolog 1.15.0 mkdir fix

    monolog 1.15.0 mkdir fix

    Monolog, as of 1.15.0, tries to create a dir on every log action and raises an exception. Slim-Monolog creates an unused monolog instance with an invalid log dir in its constructor.

    opened by bladi87 0
  • Installation and usage issues

    Installation and usage issues

    Are the installation instructions missing something or am I? Shouldn't the install be:

    composer require flynsarmy/slim-monolog

    The installation instructions in the README shows usage, not installing.

    I did the composer require as shown above, as I assume that this was assumed? But then I get the following error:

    Fatal error: Uncaught Error: Class 'Slim\Log' not found in /var/www/server/public/index.php:10 Stack trace: #0 {main} thrown in /var/www/server/public/index.php on line 10
    

    I would think there should be clear install instructions and then clear usage instructions. Code that I could drop into a route and it would just work.

    opened by teckel12 0
  • Slim v3 support?

    Slim v3 support?

    Does this library support Slim v3?

    It doesn't mention any version requirement in README.md and I'm getting an error that Slim\Log colud not be found.

    I looked in Slim's source, and v2 has a \Slim\Log, while 3v does not.

    opened by JoshWillik 5
  • log directory path concatenation is wrong

    log directory path concatenation is wrong

    The newest commit for monolog 1.15.0 breaks my logging:

    $config['app']['log.writer'] = new \Flynsarmy\SlimMonolog\Log\MonologWriter(array(
        'handlers' => array(
            new \Monolog\Handler\StreamHandler(
                realpath(__DIR__ . '/logs')
                    .'/'.$_ENV['SLIM_MODE'] . '_' .date('Y-m-d').'.log'
            ),
        ),
    ));
    

    I get this error:

    Fatal error: Uncaught exception 'UnexpectedValueException' with message 'There is no existing directory at "./logs" and its not buildable: Permission denied'
    

    When I output the $stream in StreamHandler->construct() i get:

    mylocalhost/mysite/logs/development_2015-07-17.log./logs/15-07-17.log
    

    It seems like the path concatenation is somehow off.

    opened by elburro1887 7
  • Passing context information to Monolog

    Passing context information to Monolog

    Is it possible to pass context information to Monolog?

    Slim's logging overview mentions the ability to pass mixed information but I haven't been able to sort out any way to pass context information through slim-monolog to Monolog.

    opened by grantlucas 2
Releases(v1.0.1)
Owner
null
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
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
A Simple Logging Class For PHP

KLogger: Simple Logging for PHP A project written by Kenny Katzgrau and Dan Horrigan. About KLogger is an easy-to-use PSR-3 compliant logging class fo

Kenny Katzgrau 964 Dec 11, 2022
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
🐣 Backend-Logging aller Aktionen im Backend

Addon BE_Logger - Backend-Logging Mit dem Addon be_logger können die Backend-Zugriffe aller Benutzer in einer Logging-Tabelle ausgegeben werden. Es gi

Friends Of REDAXO 14 Sep 12, 2022
This package is for centralized logging of multiple Laravel application into one connection.

Laralogs This package is for centralized logging of multiple Laravel application into one connection. Installation You can install the package via com

Remon 4 Apr 26, 2022
RadPHP Logging Component

RadPHP Logging Component The Logging library provides multiple logging adapters using a simple interface. With the Logger class it is possible to send

RadPHP 9 Sep 8, 2021
High-performance API performing logging for PHP applications into files or SysLog

Logging API Table of contents: About Configuration Binding Points Logging Installation Unit Tests Reference Guide Specifications How Are Log Lines For

Lucian Gabriel Popescu 0 Jan 9, 2022
Robust, composite logger with filtering, formatting, and PSR-3 support

laminas-log ???? Русским гражданам Мы, участники Laminas, родились и живем в разных странах. У многих из нас есть друзья, родственники и коллеги как в

Laminas Project 27 Nov 24, 2022
Pico disk, Not need any database, support html5, support mp3, mp4, support streaming media, support AriaNg

Nano netdisk, Now changed to pico disk. Pico disk,does not need any database, support html5, support mp3, mp4, support streaming media, support AriaNg.

null 53 Dec 26, 2022
Aplicação criada com Slim Framework com objetivo de criar autenticação com JWT e aprender sobre o framework Slim

Slim JWT App Essa aplicação tem como foco o aprendizado do Framework Slim e também a utilização de JWT. Como rodar a Aplicação A aplicação está config

Nicolas Pereira 9 Oct 4, 2022
Best logging support into Nette Framework (@nette)

Website ?? contributte.org | Contact ????‍?? f3l1x.io | Twitter ?? @contributte Usage To install the latest version of contributte/monolog use Compose

Contributte 21 Dec 1, 2022
Amazon Web Services CloudWatch Logs Handler for Monolog library

AWS CloudWatch Logs Handler for Monolog Handler for PHP logging library Monolog for sending log entries to AWS CloudWatch Logs service. Before using t

Maksym Leonov 377 Dec 16, 2022
This tool can write the monolog standard log directly to clickhouse in real time via the tcp protocol

log2ck This tool can write the monolog standard log directly to clickhouse in real time via the tcp protocol. If you can write regular rules, other st

Hisune 9 Aug 15, 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
Slim Auth is an authorization and authentication library for the Slim Framework.

Slim Auth is an authorization and authentication library for the Slim Framework. Authentication is provided by the Zend Framework Zend\Authentication component, and authorization by the Zend Framework Zend\Permissions\Acl component.

Jeremy Kendall 246 Dec 16, 2022
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
😎 Tracy: the addictive tool to ease debugging PHP code for cool developers. Friendly design, logging, profiler, advanced features like debugging AJAX calls or CLI support. You will love it.

Tracy - PHP debugger Introduction Tracy library is a useful helper for everyday PHP programmers. It helps you to: quickly detect and correct errors lo

Nette Foundation 1.6k Dec 23, 2022
Multilanguage support for Slim framework 2

slim-multilanguage This is an extension to the SLIM framework vers.2 to enable simple route localization. ##Installation Add dependecy to composer.jso

Simone Todaro 15 Jul 11, 2021