for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php declare( strict_types=1 );
namespace BotRiconferme\Logger;
use BotRiconferme\Config;
use BotRiconferme\Wiki\Page\Page;
use Psr\Log\AbstractLogger;
use Psr\Log\LogLevel;
/**
* Logger that sends messages on-wiki
*/
class WikiLogger extends AbstractLogger implements IFlushingAwareLogger {
use LoggerTrait;
/** @var Page */
private $logPage;
/** @var int */
protected $minLevel;
/** @var string[] */
protected $buffer;
* @param Page $logPage
* @param string $minlevel
public function __construct( Page $logPage, $minlevel = LogLevel::INFO ) {
$this->minLevel = $this->levelToInt( $minlevel );
$this->logPage = $logPage;
}
* @inheritDoc
* @suppress PhanUnusedPublicMethodParameter
public function log( $level, $message, array $context = [] ) {
if ( $this->levelToInt( $level ) >= $this->minLevel ) {
$this->buffer[] = $this->getFormattedMessage( $level, $message );
* @return string
protected function getOutput() : string {
$line = str_repeat( '-', 80 );
return implode( "\n", $this->buffer ) . "\n$line\n\n";
public function flush() : void {
if ( $this->buffer ) {
$this->logPage->edit( [
'appendtext' => $this->getOutput(),
'summary' => Config::getInstance()->getWikiMessage( 'error-page-summary' )
] );