Skip to content

Commit

Permalink
new icons configuration for defining default icons.. most plugins/cha…
Browse files Browse the repository at this point in the history
…nnels still allow defining icon
  • Loading branch information
bkdotcom committed Nov 18, 2024
1 parent 37a64c3 commit a53c9f8
Show file tree
Hide file tree
Showing 45 changed files with 265 additions and 214 deletions.
34 changes: 22 additions & 12 deletions dev/ComposerScripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,28 @@ private static function installDependencies()
$info = array(
'haveSlevomat' => false,
);
$isCi = \filter_var(\getenv('CI'), FILTER_VALIDATE_BOOLEAN);
self::installUnitTestDependencies();
if (\filter_var(\getenv('CI'), FILTER_VALIDATE_BOOLEAN)) {
return $info;
}
if (PHP_VERSION_ID >= 80000) {
\exec($composer . ' require vimeo/psalm ^5.22.2 --dev --with-all-dependencies --no-scripts');
}
if (PHP_VERSION_ID >= 70200) {
\exec($composer . ' require slevomat/coding-standard ^8.9.0 --dev --no-scripts');
$info['haveSlevomat'] = true;
}
return $info;
}

/**
* Install dependencies needed for unit tests
*
* @return void
*/
private static function installUnitTestDependencies()
{
$composer = $GLOBALS['argv'][0];
PHP_VERSION_ID >= 80000
// need a newer version to avoid ReturnTypeWillChange fatal
// v 2.0 requires php 7.0
Expand All @@ -100,17 +121,6 @@ private static function installDependencies()
if (PHP_VERSION_ID >= 50500) {
\exec($composer . ' require guzzlehttp/guzzle --dev --no-scripts');
}
if ($isCi) {
return $info;
}
if (PHP_VERSION_ID >= 80000) {
\exec($composer . ' require vimeo/psalm ^5.22.2 --dev --with-all-dependencies --no-scripts');
}
if (PHP_VERSION_ID >= 70200) {
\exec($composer . ' require slevomat/coding-standard ^8.9.0 --dev --no-scripts');
$info['haveSlevomat'] = true;
}
return $info;
}

/**
Expand Down
72 changes: 54 additions & 18 deletions src/Debug/AbstractDebug.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,31 +180,16 @@ public function onConfig(Event $event)
return;
}
$valActions = \array_intersect_key(array(
'logServerKeys' => function ($val) {
// don't append, replace
$this->cfg['logServerKeys'] = array();
return $val;
},
'channelIcon' => [$this, 'onCfgChannelIcon'],
'logServerKeys' => [$this, 'onCfgLogServerKeys'],
'serviceProvider' => [$this, 'onCfgServiceProvider'],
), $cfg);
foreach ($valActions as $key => $callable) {
/** @psalm-suppress TooManyArguments */
$cfg[$key] = $callable($cfg[$key]);
}
$this->cfg = $this->arrayUtil->mergeDeep($this->cfg, $cfg);
/*
propagate updated vals to child channels
*/
$channels = $this->getChannels(false, true);
if (empty($channels)) {
return;
}
$event['debug'] = $cfg;
$cfg = $this->rootInstance->getPlugin('channel')->getPropagateValues($event->getValues());
unset($cfg['currentSubject'], $cfg['isTarget']);
foreach ($channels as $channel) {
$channel->config->set($cfg);
}
$this->onConfigPropagate($event, $cfg);
}

/**
Expand Down Expand Up @@ -402,4 +387,55 @@ private function bootstrapSetInstances($cfg)
$this->rootInstance = $this->parentInstance->rootInstance;
}
}

/**
* Handle "channelIcon" config update
*
* @param string|null $val config value
*
* @return string|null
*/
private function onCfgChannelIcon($val)
{
if (\preg_match('/^:(.+):$/', (string) $val, $matches)) {
$val = $this->getCfg('icons.' . $matches[1], Debug::CONFIG_DEBUG);
}
return $val;
}

/**
* Handle "channelIcon" config update
*
* @param string|null $val config value
*
* @return string|null
*/
private function onCfgLogServerKeys($val)
{
// don't append, replace
$this->cfg['logServerKeys'] = array();
return $val;
}

/**
* Propagate updated vals to child channels
*
* @param Event $event Debug::EVENT_CONFIG Event instance
* @param array $cfg Debug config values
*
* @return void
*/
private function onConfigPropagate(Event $event, array $cfg)
{
$channels = $this->getChannels(false, true);
if (empty($channels)) {
return;
}
$event['debug'] = $cfg;
$cfg = $this->rootInstance->getPlugin('channel')->getPropagateValues($event->getValues());
unset($cfg['currentSubject'], $cfg['isTarget']);
foreach ($channels as $channel) {
$channel->config->set($cfg);
}
}
}
4 changes: 2 additions & 2 deletions src/Debug/Collector/AbstractAsyncMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class AbstractAsyncMiddleware extends AbstractComponent
{
protected $cfg = array(
'asyncResponseWithRequest' => true,
'icon' => 'fa fa-exchange',
'iconAsync' => 'fa fa-random',
'icon' => ':send-receive:',
'iconAsync' => ':asynchronous:',
'idPrefix' => '',
'inclRequestBody' => false,
'inclResponseBody' => false,
Expand Down
2 changes: 1 addition & 1 deletion src/Debug/Collector/DatabaseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ trait DatabaseTrait
protected $loggedStatements = array();

/** @var string */
protected $icon = 'fa fa-database';
protected $icon = ':database:';

/**
* Logs StatementInfo
Expand Down
2 changes: 1 addition & 1 deletion src/Debug/Collector/DoctrineMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class DoctrineMiddleware implements MiddlewareInterface
protected $debug;

/** @var string */
protected $icon = 'fa fa-database';
protected $icon = ':database:';

/**
* Constructor
Expand Down
10 changes: 5 additions & 5 deletions src/Debug/Collector/OAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class OAuth extends OAuthBase
protected $debugger;

/** @var string */
protected $icon = 'fa fa-handshake-o';
protected $icon = ':authorize:';

/** @var float */
private $elapsed;
Expand Down Expand Up @@ -198,15 +198,15 @@ private function logRequest($url)
// values available in the headers or elsewhere
$this->debugger->log('OAuth Parameters', $this->oauthParams(), $this->debugger->meta('cfg', 'abstracter.stringMinLen.encoded', -1));
$this->debugger->log('additional info', $this->additionalInfo($url));
$this->debugger->log('request headers', $this->debugger->redactHeaders($debugInfo['headers_sent']), $this->debugger->meta('icon', 'fa fa-arrow-right'));
$this->debugger->log('request headers', $this->debugger->redactHeaders($debugInfo['headers_sent']), $this->debugger->meta('icon', ':send:'));
if (isset($debugInfo['body_sent'])) {
$this->debugger->log('request body', $debugInfo['body_sent'], $this->debugger->meta(array(
'icon' => 'fa fa-arrow-right',
'icon' => ':send:',
'redact' => true,
)));
}
$this->debugger->log('response headers', $debugInfo['headers_recv'], $this->debugger->meta('icon', 'fa fa-arrow-left'));
$this->debugger->log('response body', $debugInfo['body_recv'], $this->debugger->meta('icon', 'fa fa-arrow-left'));
$this->debugger->log('response headers', $debugInfo['headers_recv'], $this->debugger->meta('icon', ':receive:'));
$this->debugger->log('response body', $debugInfo['body_recv'], $this->debugger->meta('icon', ':receive:'));
if ($this->exception) {
$this->debugger->warn(\get_class($this->exception), $this->exception->getMessage());
}
Expand Down
2 changes: 1 addition & 1 deletion src/Debug/Collector/PhpCurlClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class PhpCurlClass extends Curl
private $debug;

/** @var string */
private $icon = 'fa fa-exchange';
private $icon = ':send-receive:';

/** @var array<string,mixed> */
private $debugOptions = array(
Expand Down
2 changes: 1 addition & 1 deletion src/Debug/Collector/SimpleCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class SimpleCache implements CacheInterface
protected $cache;

/** @var string */
protected $icon = 'fa fa-cube';
protected $icon = ':cache:';

/** @var list<CallInfo> */
protected $loggedActions = array();
Expand Down
2 changes: 1 addition & 1 deletion src/Debug/Collector/SoapClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class SoapClient extends SoapClientBase
private $debug;

/** @var string */
protected $icon = 'fa fa-exchange';
protected $icon = ':send-receive:';

/** @var \DOMDocument */
private $dom;
Expand Down
2 changes: 1 addition & 1 deletion src/Debug/Collector/SwiftMailerLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class SwiftMailerLogger implements
protected $messages = array();

/** @var string */
protected $icon = 'fa fa-envelope-o';
protected $icon = ':email:';

/** @var string */
protected $iconMeta;
Expand Down
2 changes: 1 addition & 1 deletion src/Debug/Collector/TwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
class TwigExtension extends ProfilerExtension
{
/** @var string */
protected $icon = 'fa fa-file-text-o';
protected $icon = ':template:';

/** @var Debug */
private $debug;
Expand Down
122 changes: 49 additions & 73 deletions src/Debug/Debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class Debug extends AbstractDebug

/** @var array<string,mixed> */
protected $cfg = array(
'channelIcon' => 'fa fa-list-ul',
'channelIcon' => ':log:',
'channelName' => 'general', // channel or tab name
'channels' => array(
/*
Expand Down Expand Up @@ -156,6 +156,30 @@ class Debug extends AbstractDebug
'extensionsCheck' => ['curl', 'mbString'],
'headerMaxAll' => 250000,
'headerMaxPer' => null,
'icons' => array(
'asynchronous' => 'fa fa-random',
'authorize' => 'fa fa-handshake-o',
'cache' => 'fa fa-cube',
'component' => 'fa fa-puzzle-piece',
'config' => 'fa fa-cogs',
'database' => 'fa fa-database',
'email' => 'fa fa-envelope-o',
'event' => 'fa fa-bell-o',
'files' => 'fa fa-files-o',
'github' => 'fa fa-github fa-lg',
'loading' => 'fa fa-spinner fa-pulse fa-2x fa-fw',
'log' => 'fa fa-list-ul',
'models' => 'fa fa-cubes',
'php' => '<i class="fa" style="position:relative; top:2px; font-size:15px;">🐘</i>',
'receive' => 'fa fa-arrow-left',
'security' => 'fa fa-shield',
'send' => 'fa fa-arrow-right',
'send-receive' => 'fa fa-exchange',
'session' => 'fa fa-suitcase',
'shutdown' => 'fa fa-power-off',
'template' => 'fa fa-file-text-o',
'user' => 'fa fa-user-o',
),
'key' => null,
'logEnvInfo' => array( // may be set by passing a list
'errorReporting' => true,
Expand All @@ -181,78 +205,30 @@ class Debug extends AbstractDebug
'output' => false, // output the log?
'outputHeaders' => true, // ie, ChromeLogger and/or firePHP headers
'plugins' => array(
'channel' => array(
'class' => 'bdk\Debug\Plugin\Channel',
),
'configEvents' => array(
'class' => 'bdk\Debug\Plugin\ConfigEvents',
),
'internalEvents' => array(
'class' => 'bdk\Debug\Plugin\InternalEvents',
),
'logEnv' => array(
'class' => 'bdk\Debug\Plugin\LogEnv',
),
'logFiles' => array(
'class' => 'bdk\Debug\Plugin\LogFiles',
),
'logPhp' => array(
'class' => 'bdk\Debug\Plugin\LogPhp',
),
'logRequest' => array(
'class' => 'bdk\Debug\Plugin\LogRequest',
),
'logResponse' => array(
'class' => 'bdk\Debug\Plugin\LogResponse',
),
'methodAlert' => array(
'class' => 'bdk\Debug\Plugin\Method\Alert',
),
'methodBasic' => array(
'class' => 'bdk\Debug\Plugin\Method\Basic',
),
'methodClear' => array(
'class' => 'bdk\Debug\Plugin\Method\Clear',
),
'methodCount' => array(
'class' => 'bdk\Debug\Plugin\Method\Count',
),
'methodGeneral' => array(
'class' => 'bdk\Debug\Plugin\Method\General',
),
'methodGroup' => array(
'class' => 'bdk\Debug\Plugin\Method\Group',
),
'methodOutput' => array(
'class' => 'bdk\Debug\Plugin\Method\Output',
),
'methodProfile' => array(
'class' => 'bdk\Debug\Plugin\Method\Profile',
),
'methodReqRes' => array(
'class' => 'bdk\Debug\Plugin\Method\ReqRes',
),
'methodTable' => array(
'class' => 'bdk\Debug\Plugin\Method\Table',
),
'methodTime' => array(
'class' => 'bdk\Debug\Plugin\Method\Time',
),
'methodTrace' => array(
'class' => 'bdk\Debug\Plugin\Method\Trace',
),
'prettify' => array(
'class' => 'bdk\Debug\Plugin\Prettify',
),
'redaction' => array(
'class' => 'bdk\Debug\Plugin\Redaction',
),
'route' => array(
'class' => 'bdk\Debug\Plugin\Route',
),
'runtime' => array(
'class' => 'bdk\Debug\Plugin\Runtime',
),
'channel' => array( 'class' => 'bdk\Debug\Plugin\Channel' ),
'configEvents' => array( 'class' => 'bdk\Debug\Plugin\ConfigEvents' ),
'internalEvents' => array( 'class' => 'bdk\Debug\Plugin\InternalEvents' ),
'logEnv' => array( 'class' => 'bdk\Debug\Plugin\LogEnv' ),
'logFiles' => array( 'class' => 'bdk\Debug\Plugin\LogFiles' ),
'logPhp' => array( 'class' => 'bdk\Debug\Plugin\LogPhp' ),
'logRequest' => array( 'class' => 'bdk\Debug\Plugin\LogRequest' ),
'logResponse' => array( 'class' => 'bdk\Debug\Plugin\LogResponse' ),
'methodAlert' => array( 'class' => 'bdk\Debug\Plugin\Method\Alert' ),
'methodBasic' => array( 'class' => 'bdk\Debug\Plugin\Method\Basic' ),
'methodClear' => array( 'class' => 'bdk\Debug\Plugin\Method\Clear' ),
'methodCount' => array( 'class' => 'bdk\Debug\Plugin\Method\Count' ),
'methodGeneral' => array( 'class' => 'bdk\Debug\Plugin\Method\General' ),
'methodGroup' => array( 'class' => 'bdk\Debug\Plugin\Method\Group' ),
'methodOutput' => array( 'class' => 'bdk\Debug\Plugin\Method\Output' ),
'methodProfile' => array( 'class' => 'bdk\Debug\Plugin\Method\Profile' ),
'methodReqRes' => array( 'class' => 'bdk\Debug\Plugin\Method\ReqRes' ),
'methodTable' => array( 'class' => 'bdk\Debug\Plugin\Method\Table' ),
'methodTime' => array( 'class' => 'bdk\Debug\Plugin\Method\Time' ),
'methodTrace' => array( 'class' => 'bdk\Debug\Plugin\Method\Trace' ),
'prettify' => array( 'class' => 'bdk\Debug\Plugin\Prettify' ),
'redaction' => array( 'class' => 'bdk\Debug\Plugin\Redaction' ),
'route' => array( 'class' => 'bdk\Debug\Plugin\Route' ),
'runtime' => array( 'class' => 'bdk\Debug\Plugin\Runtime' ),
),
'redactKeys' => [ // case-insensitive
'password',
Expand Down
2 changes: 1 addition & 1 deletion src/Debug/Framework/Cake4.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public function onMiddleware(Event $event)
protected function logEvents()
{
$debug = $this->debug->getChannel('Events', array(
'channelIcon' => 'fa fa-bell-o',
'channelIcon' => ':event:',
'nested' => false,
));

Expand Down
Loading

0 comments on commit a53c9f8

Please sign in to comment.