<?php

namespace iDServer;

use Analog\Handler\Ignore;
use Analog\Logger;

class Log
{
    /**
     * @var Logger
     */
    private static $log;

    /**
     * Load logger
     *
     * Initialize default logger if there is no logger set (no logging by default)
     */
    private static function loadLogger()
    {
        if (!self::$log) {
            self::$log = new Logger();
            self::$log->handler(Ignore::init());
        }

        return self::$log;
    }

    /**
     * @param string $msg
     */
    public static function debug($msg)
    {
        self::loadLogger()->debug($msg);
    }

    /**
     * @param string $msg
     */
    public static function error($msg)
    {
        self::loadLogger()->alert($msg);
    }

    /**
     * Set the logger object.
     *
     * @param Logger $log An analog logger object.
     */
    public static function setLogger($log)
    {
        self::$log = $log;
    }
}
