/stdio-log

STDIO's Package Log Laravel

Primary LanguagePHP

Documentation

Getting started with StdioLogHelper, use Composer command to add the package to your Laravel project's dependencies.

composer require justinianus/stdio-log
composer dump-autoload

Then register new package service provider to config/app.php

'providers' => [
	Justinianus\StdioLog\StdioServiceProvider::class,
],

Setup Channel

Create new channel 'slack-log' for Slack message into config/logging.php to send message log via Slack

'slack-log' => [
	'driver' => 'slack',
	'url' => env('LOG_SLACK_WEBHOOK_URL'),
	'username' => 'Laravel Log',
	'emoji' => ':boom:',
	'level' => env('LOG_LEVEL', 'critical'),
],

Add environment variable into .env for the incoming webhook receive from Slack application.

LOG_SLACK_WEBHOOK_URL=YOUR_INCOMING_WEBHOOK_SLACK_URL

Usage

Declare library before using.

use Justinianus\StdioLog\Helpers\StdioLogHelper;

Log for Back-End

StdioLogHelper::writeFileLog(StdioLogHelper::LOG_LEVEL_CONST, 'log-channel-name', Exception $exception, Request $request, [$booleanSendSlack]);

Callback for Front-End

StdioLogHelper::callback(Request $request, [$booleanSendSlack, StdioLogHelper::LOG_LEVEL_CONST, 'log-channel-name']);