wesmiler 49c9183352 wesmiler 2 years ago
..
.github 49c9183352 wesmiler 2 years ago
src 49c9183352 wesmiler 2 years ago
tests 49c9183352 wesmiler 2 years ago
.gitattributes 49c9183352 wesmiler 2 years ago
.gitignore 49c9183352 wesmiler 2 years ago
.php-cs-fixer.php 49c9183352 wesmiler 2 years ago
CHANGELOG.md 644ec6fffd wesmiler 2 years ago
LICENSE 644ec6fffd wesmiler 2 years ago
README.md 644ec6fffd wesmiler 2 years ago
composer.json 644ec6fffd wesmiler 2 years ago
phpstan.neon 644ec6fffd wesmiler 2 years ago
phpunit.xml 49c9183352 wesmiler 2 years ago

README.md

Supports

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

handle with array/config/log/guzzle etc.

About log

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

class ApplicationLogger
{
    private static $logger;

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

    /**
     * Forward call.
     *
     * @author yansongda <me@yansongda.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 yansongda <me@yansongda.cn>
     *
     * @return Log
     */
    public static function getLogger()
    {
        if (! self::$logger instanceof Logger) {
            self::$logger = new Log();
        }   

        return self::$logger;
    }
}

Usage

After registerLog, you can use Log service:


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