<?php

use Monolog\Formatter\LineFormatter;
use Monolog\Handler\FirePHPHandler;
use Monolog\Logger;
use Monolog\Handler\RotatingFileHandler;
use Monolog\Processor\IntrospectionProcessor;



class BillDeskLogger {
    const DEFAULT_CHANNEL = 'default';

    static function logger($channel) {
        $logger = new Logger($channel);
        
        $level = (defined('WP_DEBUG') && WP_DEBUG) ? Logger::DEBUG : Logger::INFO;
        $fileStream = new RotatingFileHandler( dirname( __FILE__ ) . "/logs/virtuemart_billdesk.log", $level);

        $dateFormat = "Y-m-d H:i:s e";
        $output = "%datetime% [%channel%.%level_name%] %message% - %context% %extra%\n";
        $formatter = new LineFormatter($output, $dateFormat);

        $fileStream->setFormatter($formatter);

            if (defined('WP_DEBUG') && WP_DEBUG) {
                
            $logger->pushHandler(new FirePHPHandler());
        }

        $logger->pushProcessor(new IntrospectionProcessor());
        $logger->pushHandler($fileStream);
        return $logger;
    }

    static function defaultLogger() {
        return BillDeskLogger::logger(BillDeskLogger::DEFAULT_CHANNEL);
    }
}
