Giter Site home page Giter Site logo

Comments (5)

timkelty avatar timkelty commented on June 5, 2024

Not sure if this is the best solution, but I've fixed this by registering my own shutdown function:

<?php

namespace craftnet\logs;

use Bugsnag\Client;
use Bugsnag\Shutdown\ShutdownStrategyInterface;
use Craft;

/**
 * Class PhpShutdownStrategy.
 *
 * Use the built-in PHP shutdown function
 */
class PhpShutdownStrategy implements ShutdownStrategyInterface
{
    /**
     * @param Client $client
     *
     * @return void
     */
    public function registerShutdownStrategy(Client $client): void
    {
        register_shutdown_function(static function() use($client) {
            Craft::$app->getLog()->logger->flush(true);
            $client->flush();
        });
    }
}

Sidenote: it would be nice if Bugsnag\Client::make accepted an argument to pass the shutdownStrategy.

from bugsnag-php.

yousif-bugsnag avatar yousif-bugsnag commented on June 5, 2024

Hi @timkelty, just to confirm, does this issue only occur when batch sending is enabled?

from bugsnag-php.

timkelty avatar timkelty commented on June 5, 2024

@yousif-bugsnag correct – if I disable batch sending, it works, because it sends them immediately and doesn't need to wait for the shutdown handler

from bugsnag-php.

johnkiely1 avatar johnkiely1 commented on June 5, 2024

HI @timkelty,

The Yii2 framework is not something we officially support as there are some more significant differences to other PHP frameworks. I suspect the issue you are reporting could be due to these differences. Full support for Yii2 is on our roadmap but I don't have a timeframe at the moment. I have noted your interest and use case and will let you know here as soon as we have updates.

For now your workaround would seem perfectly reasonable if it is suiting your needs.

As a slight aside, there is a third party Yii2 Bugsnag notifier library that someone has created, so that might be of interest to you: https://github.com/pinfirestudios/yii2-bugsnag. However its worth noting Bugsnag has no connection to this so we cannot support it nor verify if it works correctly.

from bugsnag-php.

timkelty avatar timkelty commented on June 5, 2024

@johnkiely1 thanks!

FWIW, this is for Craft CMS@4 (Yii2 under the hood), which uses Monolog for logging, so we're currently getting Bugsnag integration through https://packagist.org/packages/mead-steve/mono-snag

from bugsnag-php.

Related Issues (20)

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.