Giter Site home page Giter Site logo

Comments (27)

 avatar commented on May 22, 2024 1

I've just submitted #92 for Slack support. Also submitted Seldaek/monolog#377 @Seldaek to add support to monolog SlackHandler for the emoji icons used by Slack.

Example conifg:

slack:
            type: slack
            token: xxxxxxx
            channel: C9342CD
            bot_name: YourBotName
            use_attachment: true
            icon_emoji: monkey_face
            level: error

from monolog-bundle.

moonbeamglitterblossom avatar moonbeamglitterblossom commented on May 22, 2024 1

Is there any way Rocket.Chat can be added to this list?

from monolog-bundle.

stof avatar stof commented on May 22, 2024 1

Define a service for your handler and use the service type in the MonologBundle config

from monolog-bundle.

wheelsandcogs avatar wheelsandcogs commented on May 22, 2024

It looks like ChromePHP and Gelf support are now included, so I'd like to add support for the MongoDB handler, but I'm not sure of the best approach. Following the existing handler config would give something like:

<?php
// ..... snip ....

case 'mongodb':
    $definition->setArguments(array(
        new \Mongo($handler['host']),
        $handler['database'],
        $handler['collection'],
        $handler['level'],
        $handler['bubble'],
    ));
    break;

and allow a config like:

monolog:
    handlers:
        main:
            type:  stream
            path:  %kernel.logs_dir%/%kernel.environment%.log
            level: debug
        mongo:
            type: mongodb
            host: mongodb://localhost:27017
            database: logs
            collection: prod
            level: debug
            bubble: true

Creating the Mongo instance there is clearly not the correct way to do it, but I don't know the Service or DI layers well enough to know how to inject it correctly? Also, if I'm using Doctrine MongoDB ODM, it would be nice to be able to reuse the connection thats already been configured for that so that I don't have to maintain two separate configs.

Any ideas?

from monolog-bundle.

Seldaek avatar Seldaek commented on May 22, 2024

We could have an id: @foo.bar instead of host: mongodb://localhost:27017 (though that should also remain possible IMO if you only use mongo for logging). If it's provided you just use a new Reference($handler['id']) instead of that new Mongo.

You can look at the Gelf config for inspiration: https://github.com/symfony/MonologBundle/blob/master/DependencyInjection/MonologExtension.php#L133-148

from monolog-bundle.

florianeckerstorfer avatar florianeckerstorfer commented on May 22, 2024

@Seldaek I've tried to implement this as you described, however I end up with a circular reference.

The problem is that Doctrine\MongoDB\Connection only returns a \Mongo object after it has been initialised (with the method initialize and that at that point Doctrine requires a Monolog logger.

Any suggestions how this can be implemented?

from monolog-bundle.

stof avatar stof commented on May 22, 2024

@florianeckerstorfer you have to use a mongo connection with logging disabled if you want to get it from the doctrine connection.

from monolog-bundle.

pacoVela avatar pacoVela commented on May 22, 2024

Is anyone working in mongodb handler?

from monolog-bundle.

Seldaek avatar Seldaek commented on May 22, 2024

I don't think so. I looked into it but it seemed non-trivial to wire up the doctrine mongo stuff etc so I gave up. If you'd like to give it a shot it would be much appreciated.

from monolog-bundle.

pacoVela avatar pacoVela commented on May 22, 2024

I'm wondering if doctrine is really necessary here. We can make the connection with a simple service, or directly with host/port/user/pass params. So you can use the same params for doctrine and monolog configurations, but it's only a matter of taste.

I agree with you that it is not trivial to do it with doctrine.

from monolog-bundle.

wheelsandcogs avatar wheelsandcogs commented on May 22, 2024

My concern was duplicating the config if you were already using doctrine, and possibly the overhead of having another connection just for logging. Obviously it would be nicer to re-use the existing config and connection if possible, but I'd rather have a working mongodb handler with extra config than no handler at all.

from monolog-bundle.

pacoVela avatar pacoVela commented on May 22, 2024

Using params you don't have to repeat the literals for database host, and user... So you're true, the only caveat here is the overhead by the existence of another connection. In my case this is needed because we use a server just for logs.

from monolog-bundle.

pacoVela avatar pacoVela commented on May 22, 2024

I have the mongodb basic implementation ready to merge, (without doctrine stuff).
https://github.com/pacoVela/MonologBundle

from monolog-bundle.

kingcrunch avatar kingcrunch commented on May 22, 2024

It looks like the list in the initial description isn't up to date anymore?

from monolog-bundle.

Seldaek avatar Seldaek commented on May 22, 2024

@kingcrunch care to elaborate? I usually try to update it but maybe I missed one.

from monolog-bundle.

kingcrunch avatar kingcrunch commented on May 22, 2024

@Seldaek I meant the list in this PR (above). I cannot edit that.

from monolog-bundle.

Seldaek avatar Seldaek commented on May 22, 2024

Yes I can update it but what is not up to date exactly?

from monolog-bundle.

emgiezet avatar emgiezet commented on May 22, 2024

I will add here the errbit / airbrake handler if its possible.

from monolog-bundle.

Seldaek avatar Seldaek commented on May 22, 2024

@emgiezet not sure what these have to do with monolog? Are there handlers out there somewhere that I don't know of?

from monolog-bundle.

mpdude avatar mpdude commented on May 22, 2024

Support for the WhatFailureGroupHandler is in #107.

from monolog-bundle.

PSF1 avatar PSF1 commented on May 22, 2024

I found a RocketChat Monolog handler that may simplify integration with Symfony: https://github.com/exileed/rocketchat-monolog by @exileed

from monolog-bundle.

PSF1 avatar PSF1 commented on May 22, 2024

I'm working in a RocketChat integration pull request.

from monolog-bundle.

PSF1 avatar PSF1 commented on May 22, 2024

Monolog project don't want add RocketChat support into main project: Seldaek/monolog#1310
Could monolog-bundle reference the @exileed's handler?

from monolog-bundle.

PSF1 avatar PSF1 commented on May 22, 2024

This way? https://symfony.com/doc/current/logging/handlers.html

# config/packages/prod/monolog.yaml
monolog:
    handlers:
        es:
            type: service
            id: Symfony\Bridge\Monolog\Handler\ElasticsearchLogstashHandler

from monolog-bundle.

stof avatar stof commented on May 22, 2024

yes, exactly.

from monolog-bundle.

PSF1 avatar PSF1 commented on May 22, 2024

Thx so much :_ D

I have it working with less problems...

from monolog-bundle.

Okhoshi avatar Okhoshi commented on May 22, 2024

Support for SamplingHandler is in #471

from monolog-bundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.