<?php
/**
 * PayZen V2-Payment Module version 1.8.0 for PrestaShop 1.5-1.7. Support contact : support@payzen.eu.
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 *
 * @category  payment
 * @package   payzen
 * @author    Lyra Network (http://www.lyra-network.com/)
 * @copyright 2014-2016 Lyra Network and contributors
 * @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */

if (!defined('_PS_VERSION_')) {
    exit;
}

/**
 * Extend logger class to implement logging disable and avoid to check before every log operation
 */
class PayzenFileLogger extends FileLoggerCore
{
    protected $logs_enabled = false;

    public function __construct($logs_enabled, $level = self::INFO)
    {
        $this->logs_enabled = $logs_enabled;
        parent::__construct($level);
    }

    /**
     * log message only if logs are enabled
     *
     * @param string message
     * @param level
     */
    public function log($message, $level = self::DEBUG)
    {
        if (!$this->logs_enabled) {
            return;
        }

        parent::log($message, $level);
    }
}
