matchingood / sqs-logger
此包的最新版本(v0.1)没有可用的许可证信息。
将日志数据发送到AWS SQS,适用于Laravel。
v0.1
2016-09-07 08:26 UTC
Requires
- aws/aws-sdk-php: ^3.18
- laravel/framework: ^5.2
This package is not auto-updated.
Last update: 2024-09-28 19:31:15 UTC
README
用于Laravel应用程序的AWS SQS日志库
安装
在您的composer.json文件中,
"matchingood/sqs-logger": "^0.1"
然后您在config/app.php
中注册SQSLogger。
'providers' => [ . . . Matchingood\SQSLogger\SQSLoggerServiceProvider::class ], . . . 'aliases' => [ . . . 'SQSLogger' => Matchingood\SQSLogger\Facades\SQSLogger::class ],
您可以创建配置文件来执行
$ php artisan vendor:publish
然后您可以配置app/sqslogger.php
return [
'env' => "if not 'prod', this library use Laravel Log class",
'aws' => [
'access_key' => "AWS access key",
'access_secret' => "AWS access secret",
'sqs' => [
'version' => "API version",
'region' => "AWS region",
'queue_name' => "SQS queue name"
]
]
];
使用方法
SQSLogger::info("info"); SQSLogger::error("error"); SQSLogger::critical("critical"); // Illuminate\Http\Request SQSLogger::access($request);
您可以添加更多信息,例如这样。
SQSLogger::info('info', ['hello' => 'world']);
SQS
SQSLogger在生产环境中将json数据发送到SQS。
{ "level": "INFO", "time": "2016-09-07 17:30:00", "userId": 1, "message": "Hello World!" }
当Auth::check()
返回false时,userId
属性将为-1。
只有ACCESS
级别的日志发送不同的json数据,使用Illuminate\Http\Request
作为参数。
{ "level": "INFO", "time": "2016-09-07 17:30:00", "userId": 1, "method": "POST", "accessUrl": "https://github.com/matchingood" }