lavamusic / yansongda-supports
common components
v3.2.5
2023-02-02 03:36 UTC
Requires
- php: >=7.3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- mockery/mockery: ^1.4
- monolog/monolog: ^2.0
- phpstan/phpstan: ^1.1.0
- phpunit/phpunit: ^9.0
- symfony/console: ^5.1
Suggests
- monolog/monolog: Use logger
- symfony/console: Use stdout logger
This package is not auto-updated.
Last update: 2024-11-22 11:18:54 UTC
README
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']);