silverstripe-framework/src/Logging/PreformattedEchoHandler.php
Andre Kiste 2bcf8b5ff3 More verbose file migration logging
See https://github.com/silverstripeltd/open-sourcerers/issues/91

* Add `PreformattedEchoHandler`

cherry-picked from 4c3f3e6bea99b46b689e5b23d1bd1498a4ac696c

* Batch log messages for every 100 file.
Also make logger work for stdout

* Update src/Logging/PreformattedEchoHandler.php

Co-Authored-By: bergice <bergice@users.noreply.github.com>
2019-04-30 08:54:48 +12:00

28 lines
714 B
PHP

<?php
namespace SilverStripe\Logging;
use Monolog\Handler\AbstractProcessingHandler;
/**
* Echo the output as preformatted HTML, emulating console output in a browser.
* Tiding us over until we can properly decoupled web from CLI output.
* Do not use this API outside of core modules,
* it'll likely be removed as part of a larger refactor.
*
* See https://github.com/silverstripe/silverstripe-framework/issues/5542
*
* @internal
*/
class PreformattedEchoHandler extends AbstractProcessingHandler
{
/**
* @param array $record
*/
protected function write(array $record)
{
echo sprintf('<pre>%s</pre>', htmlspecialchars($record['formatted'], ENT_QUOTES, 'UTF-8'));
}
}