GithubHelp home page GithubHelp logo

loggy's Introduction

Supports Laravel 5 writing separate log files with multiple channel.

Latest Stable Version Total Downloads License

Requirements

Loggy >= 1.0.0 requires Laravel 5.

Installation

Require this package with Composer

composer require tolawho/loggy

Quick Start

Once Composer has installed or updated your packages you need to register Loggy with Laravel itself. Open up config/app.php and find the providers key, towards the end of the file, and add Tolawho\Loggy\ServiceProvider:class, to the end:

'providers' => [
    ...
    Tolawho\Loggy\ServiceProvider::class,
],

Now find the aliases key, again towards the end of the file, and add 'Loggy' => Tolawho\Loggy\Facades\Loggy::class, to have easier access to the Loggy:

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

Now that you have both of those lines added to config/app.php we will use Artisan to publish the new config file:

php artisan vendor:publish --provider="Tolawho\Loggy\ServiceProvider"

The example config:

<?php
    
    return [
        'channels' => [
            'event' => [
                'log' => 'event.log',
                'daily' => false,
                'level' => 'debug'
            ],
            'payment' => [
                'log' => 'payment.log',
                'daily' => true,
                'level' => 'info'
            ],
        ]
    ];

Explain:

  • channels.event: The event is name of channel do you want. Ex payment, audit
  • channels.event.log: The name of log file.
  • channels.event.daily: True if you want write log file daily like as event-2017-03-31.log.
  • channels.event.level: debug, info, notice, warning, error,critical,alert,emergency

At this point you can now begin using Loggy

<?php
 
namespace App\Http\Controllers;
 
use Loggy; 
 
class HomeController extends Controller
{

    public function index()
    {
        Loggy::write('event', 'Ah hihi đồ ngốc');
        Loggy::debug('event', 'Ah hihi đồ ngốc');
        Loggy::info('event', 'Ah hihi đồ ngốc');
        
        return view('welcome');
    }
}

Configuration

Once Composer has installed or updated your packages you need to register Loggy with Laravel itself. Open up config/app.php and find the providers key towards the bottom and add:

Tolawho\Loggy\ServiceProvider::class,

You can add the Loggy Facade, to have easier access to the Loggy.

'Loggy' => Tolawho\Loggy\Facades\Loggy::class

You can find the default configuration file at vendor/tolawho/loggy/src/config.php.

You should use Artisan to copy the default configuration file from the /vendor directory to /config/loggy.php with the following command:

php artisan vendor:publish --provider="Tolawho\Loggy\ServiceProvider"

Usage

You call the Loggy like you would:

Loggy::write('payment', 'Somthing 1...', ['something 1']);
Loggy::info('payment', 'Somthing 2..', ['something 2']);

loggy's People

Contributors

sigmoswitch avatar tolawho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

loggy's Issues

Writer class

Hello!

I'm testing Loggy running this:

Loggy::info('payment_mp', 'This is a test of the emergency broadcasting system');

But the output is this:

[2017-04-21 10:03:59] payment_mp.INFO: a

In the Writer class:

    function __call($fnc, $arguments)
    {
        if ($this->levelExist($fnc)) {
            $context = isset($arguments[2]) ?'a': [];
            $message = isset($arguments[1]) ?'a': '';
            $this->put($arguments[0], $fnc, $message, $context);
        }
    }

I think this could fix the problem:

            $context = isset($arguments[2]) ? $arguments[2]: [];
            $message = isset($arguments[1]) ? $arguments[1]: '';

Thanks :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.