xyqweb / log
由wya团队创建
README
运行环境
- PHP 7.1+.
安装Log PHP SDK
composer require xyqweb/log
-
如果您使用composer管理项目依赖项,请在项目根目录中运行以下命令
composer require xyqweb/log
您也可以在
composer.json
文件中声明对Log SDK for PHP的依赖。"require": { "xyqweb/log": "~0.1" }
然后运行
composer install
来安装依赖。在Composer依赖管理器安装后,在您的PHP代码中导入依赖require_once __DIR__ . '/vendor/autoload.php';
快速使用
初始化LogClient
正常模式加载
<?php $log = new \xyqWeb\log\Log([ 'driver' => 'ssdb',//only accept file or ssdb 'host' => 'xx.xxx.xxx.xxx',//ssdb only 'port' => 'xxxxx',//ssdb only 'project' => 'xxx',//your project name 'key' => 'xxxx',//ssdb only 'path' => 'path'//log path ]); $log->write('test.log', ['content' => 'this is test content']); // You can add subdirectories here $log->write('test/test.log', ['content' => 'this is test content']); $log = new \xyqWeb\log\Log([ 'driver' => 'ssdb',//only accept file or ssdb 'host' => 'xx.xxx.xxx.xxx',//ssdb only 'port' => 'xxxxx',//ssdb only 'project' => 'xxx',//your project name 'key' => 'xxxx',//ssdb only 'path' => 'path'//log path ]); $log->write('test.log', ['content' => 'this is test content']); // You can add subdirectories here $log->write('test/test.log', ['content' => 'this is test content']);
正常模式加载yii2
'components' => [ 'yiiLog' => [ 'class' => 'xyqWeb\log\YiiLog', 'config'=>[ 'driver' => 'ssdb',//only accept file or ssdb 'host' => 'xx.xxx.xxx.xxx',//ssdb only 'port' => 'xxxxx',//ssdb only 'project' => 'xxx',//your project name 'key' => 'xxxx',//ssdb only 'path' => 'path'//log path ] ] ]
Yii::$app->yiiLog->->write('test.log', ['content' => 'this is test content']); Yii::$app->yiiLog->write('test/test.log', ['content' => 'this is test content']);