Giter Site home page Giter Site logo

laravel-discord-logger's Introduction

Laravel Discord Logger

Latest Version on Packagist Software License Total Downloads

marvinlabs/laravel-discord-logger is a laravel package providing a logging handler to send logs to a Discord channel.

Installation

You can install the package via composer:

composer require marvinlabs/laravel-discord-logger

If you are using Laravel 5.5 or later, the service provider will automatically be discovered.

On earlier versions, you need to do that manually. You must install the service provider:

// config/app.php
'providers' => [
    ...
    MarvinLabs\DiscordLogger\ServiceProvider::class
];

You can then publish the configuration file:

php artisan vendor:publish --provider "MarvinLabs\DiscordLogger\ServiceProvider"

Setup

Prepare the discord channel web hook

Create a discord web hook for the channel which will receive the logs.

Prepare the logger configuration

You must add a new channel to your config/logging.php file:

// config/logging.php
'channels' => [
    //...
    'discord' => [
        'driver' => 'custom',
        'via'    => MarvinLabs\DiscordLogger\Logger::class,
        'level'  => 'debug',
        'url'    => env('LOG_DISCORD_WEBHOOK_URL'),
    ],
];

You can then provide the web-hook URL in your .env file:

LOG_DISCORD_WEBHOOK_URL=https://discordapp.com/api/webhooks/abcd/1234

Use the logger channel

You have two options: log only to discord or add the channel to the stack

Log only to the discord channel

Simply change the .env variable to use the discord channel

LOG_CHANNEL=discord

Add the channel on top of other channels

Add the channel to the stack in the config/logging.php configuration:

// config/logging.php
'channels' => [
    //...
    'stack' => [
        'driver'   => 'stack',
        'channels' => ['single', 'discord'],
    ],
];

Then make sure the logging channel is set to stack in your .env file:

LOG_CHANNEL=stack

Logging to multiple Discord channels

Of course, you can send your log messages to multiple Discord channels. Just create as many channels as desired in config/logging.php and put them in the stack. Each channel should be named differently and should point to a different web hook URL.

What does it look like?

You can get a preview of what it looks like using each of the provided converters.

Screenshot

Version history

See the dedicated change log

Credits

License

The MIT License (MIT). Please see License File for more information.

laravel-discord-logger's People

Contributors

andjsch avatar brandondr avatar filliph avatar jespertastesen avatar jlynx avatar linc70j avatar miraries avatar pablorsk avatar shaggy84675 avatar thomasbs avatar viorelmd avatar vpratfr avatar

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.