<?php
/**
 * @package   Essentials YOOtheme Pro 2.2.16 build 0813.1608
 * @author    ZOOlanders https://www.zoolanders.com
 * @copyright Copyright (C) Joolanders, SL
 * @license   http://www.gnu.org/licenses/gpl.html GNU/GPL
 */

namespace ZOOlanders\YOOessentials\Wordpress;

use YOOtheme\Metadata;

class ConsoleLogger extends \ZOOlanders\YOOessentials\ConsoleLogger
{
    public static function print(Metadata $metadata)
    {
        if (empty(self::$LOGS)) {
            return;
        }

        $script = self::buildPrintScript(self::$LOGS);
        echo sprintf('<script>%s</script>', $script);
    }

    public static function alert(Metadata $metadata)
    {
        $errors = array_filter(self::$LOGS, function ($log) {
            return $log['type'] === 'error';
        });

        if (empty($errors)) {
            return;
        }

        $script = self::buildAlertScripts($errors);
        echo sprintf('<script>%s</script>', $script);
    }
}
