Code Monkey home page Code Monkey logo

laravel-discord-logger's People

Contributors

8ctopus avatar andreasschantl avatar brandondr avatar enanofurtivo avatar filliph avatar jespertastesen avatar kiritokatklian avatar laravel-shift avatar linc70j avatar miraries avatar pablorsk avatar sgtcoder avatar shaggy84675 avatar sibkod avatar thomasbs avatar viorelmd avatar vpratfr avatar xinecraft 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-discord-logger's Issues

default user name issue

If the laravel application has no APP_NAME, the default is taken from config/discord-logger.php, however that won't work because Discord does not allow the name to contain the keyword discord.

Exception has occurred.
GuzzleHttp\Exception\ClientException: Client error: `POST https://discord.com/api/webhooks/13424244784/hOuXo5uf0dJgdCA4_mM4uDzkgLmV2ZCHbtIh9ewR1M792g1DOE9sjxmyi0YoWRz9-Vou` resulted in a `400 Bad Request` response:
{"username": ["Username cannot contain \"discord\""]}
// config/discord-logger.php
return [

    /*
     * The author of the log messages. You can set both to null to keep the Webhook author set in Discord
     */
    'from'       => [
        'name'       => env('APP_NAME', 'Discord Logger'),
        'avatar_url' => null,
    ],

Stopped working in Laravel 7 and PHP 7.4

  • PHP 7.4
  • Laravel 7..22.2

I'm facing the following problem:

[2023-10-27 15:50:54] laravel.EMERGENCY: Unable to create configured logger. Using emergency logger. {"exception":"[object] (ParseError(code: 0): syntax error, unexpected '|', expecting variable (T_VARIABLE) at /app/vendor/marvinlabs/laravel-discord-logger/src/DiscordLogger/LogHandler.php:38)
[stacktrace]
#0 /app/vendor/composer/ClassLoader.php(427): Composer\\Autoload\\{closure}('/app/vendor/com...')
#1 [internal function]: Composer\\Autoload\\ClassLoader->loadClass('MarvinLabs\\\\Disc...')
#2 /app/vendor/marvinlabs/laravel-discord-logger/src/DiscordLogger/Logger.php(38): spl_autoload_call('MarvinLabs\\\\Disc...')
#3 /app/vendor/marvinlabs/laravel-discord-logger/src/DiscordLogger/Logger.php(32): MarvinLabs\\DiscordLogger\\Logger->newDiscordLogHandler(Array)
#4 /app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(229): MarvinLabs\\DiscordLogger\\Logger->__invoke(Array)
#5 /app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(202): Illuminate\\Log\\LogManager->createCustomDriver(Array)
#6 /app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(118): Illuminate\\Log\\LogManager->resolve('discord')
#7 /app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(98): Illuminate\\Log\\LogManager->get('discord')
#8 /app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(87): Illuminate\\Log\\LogManager->driver('discord')
#9 /app/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(261): Illuminate\\Log\\LogManager->channel('discord')
#10 /app/app/Console/Commands/Playground.php(42): Illuminate\\Support\\Facades\\Facade::__callStatic('channel', Array)
#11 /app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): App\\Console\\Commands\\Playground->handle()
#12 /app/vendor/laravel/framework/src/Illuminate/Container/Util.php(37): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#13 /app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure(Object(Closure))
#14 /app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
#15 /app/vendor/laravel/framework/src/Illuminate/Container/Container.php(596): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
#16 /app/vendor/laravel/framework/src/Illuminate/Console/Command.php(134): Illuminate\\Container\\Container->call(Array)
#17 /app/vendor/symfony/console/Command/Command.php(298): Illuminate\\Console\\Command->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#18 /app/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#19 /app/vendor/symfony/console/Application.php(1040): Illuminate\\Console\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#20 /app/vendor/symfony/console/Application.php(301): Symfony\\Component\\Console\\Application->doRunCommand(Object(App\\Console\\Commands\\Playground), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#21 /app/vendor/symfony/console/Application.php(171): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#22 /app/vendor/laravel/framework/src/Illuminate/Console/Application.php(93): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#23 /app/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#24 /app/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#25 {main}
"}

Laravel 8 Support

It would be great if this package update its support to Laravel 8!

RichRecordConverter don't show filename and line on error logs

Hi!

RichRecordConverter show all trace, but filename and line with error is missing (the most important information).

Actual behaviour

[2021-12-16 18:31:07] production.ERROR
Call to undefined method App\Model::badMethod()

Stacktrace
`#0 /app/vendor/laravel/framework/src/Illuminate/Support/Traits/ForwardsCalls.php(36): Illuminate\Database\Eloquent\Model::throwBadMethodCallException()
#1 /app/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1993): Illuminate\Database\Eloquent\Model->forwardCallTo()
...

Spected behaviour

(line On /app/Model.php(115) added)

[2021-12-16 18:31:07] production.ERROR
Call to undefined method App\Model::badMethod()
On /app/Model.php(115) 

Stacktrace
`#0 /app/vendor/laravel/framework/src/Illuminate/Support/Traits/ForwardsCalls.php(36): Illuminate\Database\Eloquent\Model::throwBadMethodCallException()
#1 /app/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1993): Illuminate\Database\Eloquent\Model->forwardCallTo()
...

image

Erorr on Payload > Embeds > url on GuzzleWebHook.php on send function

when i try logging with discord i got error with this message
Discord web hook responded with an error (400): {"embeds": ["0"]}
when i the code on GuzzleWebHook.php on send function, its send url on payload with key embeds,
when I try post to discord without embeds url, it goes success.
Can you remove the url key on payload?

Include the system's ip when logging

Hello,

I've been receiving quite a lot of problem with the logger. SInce I do have multiple running servers to run the my laravel app and it's on load balancer. I don't know which server is getting the errors.

Support Laravel 6.x and php 8

Hello guys.

Is any chance for add new version of required packages ?

"require": {
    "php": ">=7.3 | ^8.0",
    "ext-json": "*",
    "guzzlehttp/guzzle": "^6.3|^7.0|^7.5",
    "illuminate/support": "^6.0|^7.0|^8.0|^9.0"
  },

"illuminate/support": "^6.0 and "guzzlehttp/guzzle": "^7.5",

Rate Limit

Hello,

I really like this package and i use it in my applications to get the latest errors and fix them asap, but sometimes the errors spams, and i have jobs, so the discord logger gives an exception and it stops the jobs from working, because of the error exception.

so i hope there is an exception bypass to the discord rate limit, i mean by that if an error happened and discord rate limited the hook, it does not stop the app jobs from working, it pass the error.

Thank you very much again for such good & helpful package like this.

Laravel 11 support

Laravel 11 is coming. Can't install laravel-discord-logger on current master branch of the framework. I believe changing illuminate/support package version constraint will fix this.

Not working with PHP< 8.0

I was running into a problem with the package in a project using php 7.4. The issue was due to union types which is only supported after 8, so changing the union type to an untyped parameter on the "write" function in the 39th line of "LogHandler.php" file woud not change functionality and makes the package compatible with older versions of PHP (not sure how old)

Send long error messages as attachments

Hi,

First off thanks for the library, I'm very pleased with it! One thing that I've ran into - whenever your log message is longer than the allowed limit in a Discord Embed the message is truncated. I need the whole message in order to make any sense of it. In my case, users are sending serialized data to my website which I then parse. If parsing fails for whatever reason, I send the serialized data to the Discord logging channel. These strings aren't that big, but big enough for Discord to truncate the data (or you do it before you send to Discord).

For example:
image

To me that doesn't quite work since I need the entire message in order to deserialize it and make sense of the message. Can these types of messages be sent as an attachment instead like what happens with stacktraces?

Thank you for considering!

Is it possible to change the message icon?

First of all, thank you.
Thanks to this plugin, debugging in the production environment has become considerably easier.

problem

The icon changes according to the log type, this is good.
However, every time I send an error log, I'm forced to see poop, this is terrible.

For me, poop is something I only want to see in the bathroom.
Therefore, I can only use the debug() type for logs sent by this plugin.
Bugs are fine for me.

Question

Program errors are certainly poop, but I think it's fine just in your head.
I would appreciate it if you could tell me how to change it.
I'm not familiar with PHP or Laravel, is it difficult if the plugin itself needs to be changed?

Sorry for the long sentence. I am always grateful for your help.

โ€ป Sorry, This sentence was generated by Google Translate.

Logging does not show message content in discord.

Using Laravel 11

When doing a logging call in tinker like so.

Log::info('Test');

I get an empty message sent to discord.

But if I force an exception I get the file stacktrace sent to discord but still no message.

I am sure I am doing something wrong on my side.

Anyone have any advice to what it could be?

Compatibility issue with Laravel 10

I'm trying to use this package in my Laravel 10 project, but I'm encountering an error related to compatibility. I believe there is a conflict between the requirements of package and Laravel 10. Can you please help me resolve this issue?

{
    "require": {
        "php": "^8.1",
        "laravel/framework": "^10.0",
        "marvinlabs/laravel-discord-logger": "^1.3"
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}


Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - illuminate/support[v7.0.0, ..., v7.28.4] require php ^7.2.5 -> your php version (8.1.13) does not satisfy that requirement.
    - illuminate/support[v8.0.0, ..., v8.11.2] require php ^7.3 -> your php version (8.1.13) does not satisfy that requirement.
    - Root composer.json requires laravel/framework ^10.0 -> satisfiable by laravel/framework[10.x-dev].
    - marvinlabs/laravel-discord-logger[v1.3.0, ..., v1.3.1] require illuminate/support ^7.0|^8.0|^9.0 -> satisfiable by illuminate/support[v7.0.0, ..., 7.x-dev, v8.0.0, ..., 8.x-dev, v9.0.0-beta.1, ..., 9.x-dev].
    - Only one of these can be installed: illuminate/support[v7.0.0, ..., 7.x-dev, v8.0.0, ..., 8.x-dev, v9.0.0-beta.1, ..., 9.x-dev], laravel/framework[10.x-dev]. laravel/framework replaces illuminate/support and thus cannot coexist with it.
    - Root composer.json requires marvinlabs/laravel-discord-logger ^1.3 -> satisfiable by marvinlabs/laravel-discord-logger[v1.3.0, v1.3.1].

Config file says "from.name" can be null, this is not true

    /*
     * The author of the log messages. You can set both to null to keep the Webhook author set in Discord
     */
    'from'       => [
        'name'       => 'Error Logger',
        'avatar_url' => null,
    ],

Results in this error message:

   Symfony\Component\Debug\Exception\FatalThrowableError  : Return value of MarvinLabs\DiscordLogger\Converters\AbstractRecordConverter::getFromName() must be of the type string, null returned

  at /var/www/html/prod/vendor/marvinlabs/laravel-discord-logger/src/DiscordLogger/Converters/AbstractRecordConverter.php:98
     94|     }
     95| 
     96|     protected function getFromName(): string
     97|     {
  >  98|         return $this->config->get('discord-logger.from.name');
     99|     }
    100| 
    101|     protected function getFromAvatar(): ?string
    102|     {

  Exception trace:

  1   MarvinLabs\DiscordLogger\Converters\AbstractRecordConverter::getFromName()
      /var/www/html/prod/vendor/marvinlabs/laravel-discord-logger/src/DiscordLogger/Converters/AbstractRecordConverter.php:87

  2   MarvinLabs\DiscordLogger\Converters\AbstractRecordConverter::addGenericMessageFrom(Object(MarvinLabs\DiscordLogger\Discord\Message))
      /var/www/html/prod/vendor/marvinlabs/laravel-discord-logger/src/DiscordLogger/Converters/RichRecordConverter.php:19

I'm guessing it should be : ?string like the avatar?

All logs as file after a certain character length

Currently stacktraces are logged as files if enabled in the config file. However, other logs longer than 2000 characters are sent as an embed which gets truncated. It'd be great if all logs longer than 2000 are also sent as a file just like with stacktraces.

PHP Version requirement error

public function write(array|LogRecord $record): void { if ($record instanceof LogRecord) { $record = $record->toArray(); } foreach($this->recordToMessage->buildMessages($record) as $message) { try { $this->discord->send($message); } catch (\Exception $e) { if (!$this->ignoreExceptions) { throw $e; } } } }

This function doesn't works on PHP versions < 8.0

Log [discord] is not defined.

even following all the steps in the README, the application displays the error:

Log [discord] is not defined.

Any idea?

[Feat] Anti log spam

Add throttle option to log (use Cache / redis cache) to don't spam many time the same error
with 2 options : enabled, throttle time (default 3600 sec)
key is : md5(the error name, file name, and line number)

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.