taitai42 / stklog-laravel by yannis

Stklog php package for laravel
953
0
2
Package Data
Maintainer Username: yannis
Maintainer Contact: yannis.berrouag@gmail.com (yannis berrouag)
Package Create Date: 2017-05-11
Package Last Update: 2017-07-04
Language: PHP
License: bsd
Last Refreshed: 2024-11-26 15:26:07
Package Statistics
Total Downloads: 953
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

stklog-laravel

This package is a stklog wrapper to send your log to stklog. please check stklog.io for more information on how to get your project_key

Install

Via Composer

$ composer require taitai42/stklog-laravel

add the service provider to your config/app.php file

'providers' => [
    ...,
    \taitai42\Stklog\StklogServiceProvider::class,
  ],

publish the config file :

php artisan vendor:publish

you can optionnally use the provided stklog middleware that will log all of your request to your app. to do so add this line in your kernel.php file :

protected $middleware = [
 ...,
 
 taitai42\Stklog\Middleware\StklogMiddleware::class,
];

Usage

stklog-laravel package will automatically overwrite the log interface of your laravel app, meaning you can simply use your normal logging way and everything will be forwarded to stklog

you can also declare your own stack by using the stack repository :

// use taitai42\Stklog\Model\StackRepository;

StackRepository::stack('incoming request', null, $request->headers->all());
Log::info("parsing request ...");
 

You can also use this handler outside laravel, to do so simply add the new handler with the transport of your choice to your monolog instance :

<?php

use Monolog\Logger;
use taitai42\Stklog\Handler\StklogHttpHandler;

// create a log channel
$log = new Logger('name');
$log->pushHandler(new StklogHttpHandler('your-project-key', Logger::WARNING));

// add records to the log
$log->warning('Foo');
$log->error('Bar');

Todo

  • set the default log level in config
  • test nesting stack when it will be working
  • endstack by name (check nested stack)
  • add test ? (or be confident.)