Coder Social home page Coder Social logo

Comments (7)

stof avatar stof commented on July 18, 2024

The monolog API is addRecord(integer|string $level, string $message, array $context). If you want include an array (or an object) in the log record, put it inside the context. You will then see it in Firephp

from monolog.

Surt avatar Surt commented on July 18, 2024

Ouch! Thank you and sorry, it was there and I didn't saw it
Finally I managed to create a "dirty" workaround overwriting handle in FirePHPHandler.
It's not so beautiful, but I just use it on developing, so, no performance issues.

    /**
     * {@inheritdoc}
     */
    public function handle(array $record)
    {
        if ($record['level'] < $this->level) {
            return false;
        }

        if(isset($record['context']['table'])){
            require_once('Path/to/FirePHP.php');
            fb($record['context']['table'], $record['message'], 'TABLE');
        }
        else {
            return parent::handle($record);
        }
    }

using it this way

$log->debug("Benchmark", array('table'=>array(....)));

from monolog.

Seldaek avatar Seldaek commented on July 18, 2024

@Surt if you think this could be of some value in the core handler I'm not particularly against it, but I don't really use firephp so I am not sure. It seems to me like it's hard to say when something should be a table and when not. I mean it's context dependent, which is hard to solve in an abstraction.

from monolog.

Surt avatar Surt commented on July 18, 2024

Umm I'm not sure, I think that is not a good addition since it breaks a little the uniformity (don't know about other handlers).
Anyway, the issue could stay here for everyone looking for a workaround.
Anyone can drop a comment if they find the post useful.

I use the tables in this way:
Screenshot_1

by the way ;) Seldaek I can't stop using your Dwoo library. No one makes me feel like it :)

from monolog.

Seldaek avatar Seldaek commented on July 18, 2024

@Surt eh well, glad to hear but I would really recommend using twig just because dwoo is not going to receive much maintenance ever I'm afraid. And by now twig can do pretty much everything dwoo could besides the automatic php function mapping, but that is in a way for the best in terms of enforcing best practices.

from monolog.

stof avatar stof commented on July 18, 2024

@Seldaek Twig also has a way to map php functions to Twig functions automatically (but not documented and not recommended)

from monolog.

Surt avatar Surt commented on July 18, 2024

:) I know about Twig, I'm triying to use it but i don't like the syntax and need to rewrite my "plugins" again :(

About the post topic, my last contribution break the headers and nothing except tables appear on the logs, due to the Firephp core code.... so I manage to read the FirePHP Wildfire Wiki and ended with this on the "format" method of WildfireFormatter.php

        if(isset($record['context']['table'])){
            $type  = 'TABLE';
            $label = $record['message'];
            $message = $record['context']['table'];
        }
        else {
            $type  = $this->logLevels[$record['level']];
            $label = $record['channel'];
        }

        // Create JSON object describing the appearance of the message in the console
        $json = $this->toJson(array(
            array(
                'Type'  => $type,
                'File'  => $file,
                'Line'  => $line,
                'Label' => $label,
            ),
            $message
        ), $handleError);

as always, using it this way, so I can render tables at any level
$log->debug("Benchmark", array('table'=>array(....)));

The table array must be non-associative.

This code is better since it lives in the formatter and does not use the FirePHP library in any way (there was no need to use it anyway thanks to your great work)

from monolog.

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.