eurofirany / ef-log
This package is abandoned and no longer maintained.
No replacement package was suggested.
App logs
v2.2
2022-05-19 11:07 UTC
Requires
- php: ^7.4|^8.0
- eurofirany/ef-api: ^v1.5
- illuminate/support: ^8.0
- laravel-notification-channels/microsoft-teams: 1.1.0
Requires (Dev)
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.0
README
Package for creating logs
Install
composer require eurofirany/ef-log
php artisan EfLog:install
Configuration
<?php
return [
'app_name' => env('APP_NAME'),
'app_env' => env('APP_ENV'),
'app_url' => env('APP_URL'),
'logs_url' => env('APP_URL').'/ef-log/logs/',
'logs_token' => env('EF_TOKEN'),
'logs_extended_tables' => [
//
],
'logs_teams_channel_url' => env('EF_LOG_TEAMS_CHANNEL_URL'),
];
Variables for .env
EF_LOG_TEAMS_CHANNEL_URL=
Log types
INFO
SUCCESS
ERROR
WARNING
Commands for groups
php artisan EfLog:addGroup
# Optional parameters
# --name= --translation=
php artisan EfLog:removeGroup
# Optional parameter
# --name=
Commands for operations
php artisan EfLog:addOperation
# Optional parameters
# --name= --translation=
php artisan EfLog:removeOperation
# Optional parameter
# --name=
Methods
// Type
->info('TITLE')
->success('TITLE')
->error('TITLE')
->warning('TITLE')
->description('DESC') // Optional
->group('GROUP')
->operation('OPERATION')
->properties('TABLE', [
'KEY1' => 'VALUE1',
'KEY2' => 'VALUE2'
]) // Optional - Save properties in extended table
->parent($parentId) // Optional
->save() // Save log
->send() // Send notification
->show(); // Show log
Example usage
#1
EfLog::create()
->success('title')
->description('description')
->properties('Files', [
'name' => 'filename'
])
->group('Files')
->operation('Download')
->save()
->send()
->show();
#2
EfLog::create()
->error('title')
->parent('123')
->save();
#3
EfLog::create()
->info('title')
->send();
#4
EfLog::create()
->warning('title')
->description('description')
->show();
Extended tables
php artisan EfLog:extend
Define table in config
<?php
// ef_log
return [
'logs_extended_tables' => [
'Files',
]
];
Example model for extended table
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class EfLogExtendedTableFilesLog extends Model
{
public $timestamps = false;
protected $fillable = [
'log_id',
'name'
];
}
Example migration for extended table
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateEfLogExtendedTableFilesLogsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ef_log_extended_table_files_logs', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('log_id');
$table->string('name');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('ef_log_extended_table_files_logs');
}
}
Defined routes
// Api
ef-log/logs
ef-log/settings // GET|POST