matchingood / SQSLogger by kota-inamori

send logging data to AWS SQS, working on Laravel.
3,887
3
13
Package Data
Maintainer Username: kota-inamori
Package Create Date: 2016-07-29
Package Last Update: 2017-09-14
Home Page:
Language: PHP
License: Unknown
Last Refreshed: 2024-05-15 15:14:54
Package Statistics
Total Downloads: 3,887
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 3
Total Watchers: 13
Total Forks: 0
Total Open Issues: 0

SQSLogger

Loggin library for Laravel application with AWS SQS

Install

In your composer.json,

"matchingood/sqs-logger": "^0.1"

Then you register SQSLogger at config/app.php.

'providers' => [
    .
    .
    .
    Matchingood\SQSLogger\SQSLoggerServiceProvider::class
],
.
.
.
'aliases' => [
    .
    .
    .
    'SQSLogger' => Matchingood\SQSLogger\Facades\SQSLogger::class
],

You can create the configuration file to execute

$ php artisan vendor:publish

Then you can configure 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"
        ]
    ]
];

Usage

SQSLogger::info("info");
SQSLogger::error("error");
SQSLogger::critical("critical");

// Illuminate\Http\Request
SQSLogger::access($request);

You can add more information like this.

SQSLogger::info('info', ['hello' => 'world']);

SQS

SQSLogger sends json data to SQS in the production environment.

{
    "level": "INFO",
    "time": "2016-09-07 17:30:00",
    "userId": 1,
    "message": "Hello World!"
}

The userId property will be -1 when Auth::check() returns false.

Only ACCESS level sends diferent json data, using Illuminate\Http\Request as a parameter.

{
    "level": "INFO",
    "time": "2016-09-07 17:30:00",
    "userId": 1,
    "method": "POST",
    "accessUrl": "https://github.com/matchingood"
}