<?php

namespace common\helpers;

use Monolog\Handler\FirePHPHandler;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;

class LoggerTool
{
    public static function info($message)
    {
        $logger = new Logger('info');
        // 添加一些处理器
        $logger->pushHandler(new StreamHandler(__DIR__ . "/../runtime/logs/info.log", Logger::DEBUG));
        $logger->pushHandler(new FirePHPHandler());
        $logger->info(json_encode($message));
    }

    public static function error($message)
    {
        $logger = new Logger('error');
        // 添加一些处理器
        $logger->pushHandler(new StreamHandler(__DIR__ . "/../runtime/logs/error.log", Logger::DEBUG));
        $logger->pushHandler(new FirePHPHandler());
        $logger->error(json_encode($message));
    }

    public static function warning($message)
    {
        $logger = new Logger('warning');
        // 添加一些处理器
        $logger->pushHandler(new StreamHandler(__DIR__ . "/../runtime/logs/warning.log", Logger::DEBUG));
        $logger->pushHandler(new FirePHPHandler());
        $logger->warning(json_encode($message));
    }

    public static function notice($message)
    {
        $logger = new Logger('notice');
        // 添加一些处理器
        $logger->pushHandler(new StreamHandler(__DIR__ . "/../runtime/logs/notice.log", Logger::DEBUG));
        $logger->pushHandler(new FirePHPHandler());
        $logger->notice(json_encode($message));
    }

    public static function debug($message)
    {
        $logger = new Logger('debug');
        // 添加一些处理器
        $logger->pushHandler(new StreamHandler(__DIR__ . "/../runtime/logs/debug.log", Logger::DEBUG));
        $logger->pushHandler(new FirePHPHandler());
        $logger->debug(json_encode($message));
    }
}