openers/supports

通用组件

1.0.1 2022-12-29 06:50 UTC

This package is not auto-updated.

Last update: 2024-09-20 12:16:41 UTC


README

Linter Status Tester Status Latest Stable Version Total Downloads Latest Unstable Version License

使用数组/config/log/guzzle等处理

关于日志

use Estudyer\Supports\Logger as Log;
use Monolog\Logger;

class ApplicationLogger
{
    private static $logger;

    /**
     * Forward call.
     *
     * @author Estudyer <me@Estudyer.cn>
     *
     * @return mixed
     */
    public static function __callStatic(string $method, array $args)
    {
        return call_user_func_array([self::getLogger(), $method], $args);
    }

    /**
     * Forward call.
     *
     * @author Estudyer <me@Estudyer.cn>
     *
     * @return mixed
     */
    public function __call(string $method, array $args)
    {
        return call_user_func_array([self::getLogger(), $method], $args);
    }

    /**
     * Make a default log instance.
     *
     * @author Estudyer <me@Estudyer.cn>
     *
     * @return Log
     */
    public static function getLogger()
    {
        if (! self::$logger instanceof Logger) {
            self::$logger = new Log();
        }   

        return self::$logger;
    }
}

用法

在注册Log后,您可以使用日志服务


ApplicationLogger::debug('test', ['test log']);