Allow inline line breaks for Monolog

By default Monolog ignores line breaks inside debug message and puts it in one line. That’s fine for GrayLog or something similar but is not handy for me during local development. The fix is easy. Just add new Formatter with allowInlineLineBreaks option in true to your StreamHandler and enjoy formatted dumping of arrays:

$logger = new Monolog\Logger('MyLoggerName');
$formatter = new Monolog\Formatter\LineFormatter(
    null, // Format of message in log, default [%datetime%] %channel%.%level_name%: %message% %context% %extra%\n
    null, // Datetime format
    true, // allowInlineLineBreaks option, default false
    true  // ignoreEmptyContextAndExtra option, default false
);
$debugHandler = new Monolog\Handler\StreamHandler('/tmp/my_debug.log', Monolog\Logger::DEBUG);
$debugHandler->setFormatter($formatter);
$logger->pushHandler($debugHandler);

Log for Mysql console session

To log Mysql console session use option –tee (two dashes!) with full path to the log file:
mysql -uroot my_db --tee=/tmp/mysql_console.log
As result the file /tmp/mysql_console.log will contains all commands and queries with result of their executions. That might be helpful to keep your queries for using next time or for troubleshooting.

The author of the post, where I found that useful info, said that each time the Mysql session is started with logging the log file will be replaced. In my case it isn’t. As I expected the new messages just are appended to the log file.