magento-hackathon / pre-imagine-2016

7 stars 3 forks source link

Conditional logging flags and log messages #6

Open alankent opened 8 years ago

alankent commented 8 years ago

Add a logging system similar to log4j or similar in other programming languages (might already exist for PHP somewhere) where it is easy to turn on/off logging flags (even in production). Need to think through the use cases - is it wanted in production?

Must be able to turn off a flag and avoid all computation controlled by that flag. For example,

if ($logger->on()) {
    $x = {code to generate message to log}
    $logger->write($x);
}

The second half of the project is then to identify key flows in the system (e.g. matching URLs to modules to process them, or identifying which layout file to load) and define flags to turn logging on/off for that flag. This can be used to help trace system behavior (what paths did it try to open when finding all the layout files? What did the layout tree look like after each layout instruction was performed? etc) - this can make debugging easier. This use case wants environment variables or similar to turn flags on/off while debugging.

It can also be useful for extension developers if they can ask a merchant to "apply these settings and send us the captured output". Extension developers can turn on some flags, run some commands, and send the log output to the extension developer for support. So I think that use case means want something in the admin interface.

mttjohnson commented 8 years ago

Are you thinking of continuing the use of Monolog and building better support for how the use of it is implemented, or are is this more of an experiment related to Monolog alternatives?