Giter Club home page Giter Club logo

Comments (5)

pschirch avatar pschirch commented on July 27, 2024

I read in the docs that:

When the profiler is enabled, a handler is added to store the logs' messages in the profiler. The profiler uses the name "debug" so it is reserved and cannot be used in the configuration.

I figured out that the MonologBundle adds this handler with the help of an CompilerPass. I need the LoggerChannelPass instance you create in here to add my own handler.

What is the sophisticated way to do that?

from monolog-bundle.

Seldaek avatar Seldaek commented on July 27, 2024

I guess you could iterate over all services to find the monolog.logger* ones and add the pushHandler call to them.

from monolog-bundle.

pschirch avatar pschirch commented on July 27, 2024

I just managed to add my handler programmatically. But the Symfony2 implementation of the getLogs() method in the MonologBridge only offers the logs from the DebugLoggerInterface.

It should be possible to do something like that:

class DemoController extends Controller
{
    public function indexAction()
    {
        $channel = 'mychannel';
        $logs = $this->logger->getLogs($channel);
    }
}

I wont use a stream like a file to save my bundles logs. I want to get my log message to show it in an user friendly jQuery tracleog. The bundles configuration allows to enable / disable this behaviour.

from monolog-bundle.

pschirch avatar pschirch commented on July 27, 2024

For testing purpose I extend MonologBridge and add my HandlerInterface. But I think that is not a clean solution.

What do you think?

from monolog-bundle.

Seldaek avatar Seldaek commented on July 27, 2024

I don't get what you mean, a debug handler collects and returns you (in getLogs) everything that it received. If you only want one channel then either only add that handler to that channel, or filter the logs based on their channel key (though I see that this is not possible, but it could be added to the collected records array).

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.