2017 © Pedro Peláez
 

library laravel-dynamic-logger

Dynamic logger for laravel

image

rlacerda83/laravel-dynamic-logger

Dynamic logger for laravel

  • Friday, July 8, 2016
  • by rlacerda83
  • Repository
  • 1 Watchers
  • 0 Stars
  • 42 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Dynamic Log settings for Laravel

With this package you will be able to change log settings in real time., (*1)

Requirements

Laravel 5., (*2)

Installation

You can install the package using the Composer package manager. You can install it by running this command in your project root:, (*3)

composer require rlacerda83/laravel-dynamic-logger

Configuration

Add the DynamicLogger\DynamicLoggerServiceProvider provider to the providers array in config/app.php:, (*4)

'providers' => [
  DynamicLogger\DynamicLoggerServiceProvider::class,
],

Then add the facade to your aliases array:, (*5)

'aliases' => [
  ...
  'DynamicLogger' => DynamicLogger\Facades\DynamicLogger::class,
],

Usage

The DynamicLogger facade is now your interface to the library., (*6)

Note that if you're using the facade in a namespace (e.g. App\Http\Controllers in Laravel 5) you'll need to either use DynamicLogger at the top of your class to import it, or append a backslash to access the root namespace directly when calling methods, e.g. \DynamicLogger::method()., (*7)

/**
 * Use setHandlers to modify the log settings
 *
 * @param array $handlers - array handlers (monolog)
 * @param bool $logOnlyThisHandlers - If true, it ignores the default handler of laravel and uses only the handlers sent
 * @param bool $cliLogger - future improvement
 */

$file = 'path_to_log/file.log'
$handlers[] = new StreamHandler($file);
\DynamicLogger::setHandlers($handlers, true, $cliLogger);
//From that moment, the log will only be used with informed handlers

//to revert the log for default laravel settings use:
\DynamicLogger::revert();

// you can use Log::info() or you can use DynamicLogger::info()
/**
 * All log methods in DynamicLogger accept this params
 *
 * @param string $message
 * @param array $params
 * @param array $context
 */

 //Both have the same behavior
Log::info('Info message');
DynamicLogger::info('Info Message');

// DynamicLogger with params
DynamicLogger::info(
  'Event %s has been successfully started. Next event will be the %s', [$currentEvent, $nextEvent]);

The Versions

08/07 2016

dev-master

9999999-dev https://github.com/rlacerda83/laravel-dynamic-logger.git

Dynamic logger for laravel

  Sources   Download

BSD

The Requires

 

The Development Requires

by Rodrigo Lacerda

laravel logger lumen monolog