<?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;

class Logger extends Data
{
    /**
     * @var array
     */
    public static $loggers = [];

    public function __construct(string $id)
    {
        $this->id = $id;
        $this->entries = [];
    }

    public static function createLogger(string $id, string $group): self
    {
        self::$loggers[$group] = self::$loggers[$group] ?? [];

        if (isset(self::$loggers[$group][$id])) {
            return self::$loggers[$group][$id];
        }

        return self::$loggers[$group][$id] = new Logger($id);
    }

    public function logEntry(string $id, array $args): void
    {
        $this->data['entries'][] = compact('id') + $args;
    }
}
