Giter VIP home page Giter VIP logo

Comments (6)

mnapoli avatar mnapoli commented on May 30, 2024

Hi, that's an interesting approach and I like it.

However, we need to make sure that the logger does not try to write to disk: would you solution make sure of that?

from laravel-bridge.

gusiq avatar gusiq commented on May 30, 2024

Well we could filter channels to remove all that use filesystem as storage. User still could use some custom channel that writes to disk, but I think the risk is very low.

// We remove single and daily channels and ensure that stderr is used
$logDriver = Config::get('logging.default');
if ($logDriver === 'stack') {
    $channels = array_filter(Config::get('logging.channels.stack.channels', []), function ($value) {
        return !in_array($value, ['single', 'daily']);
    });
    array_push($channels, 'stderr');
    Config::set('logging.channels.stack.channels', array_unique($channels));
}

It's not a perfect solution, but I think can solve most use cases. Syslog and errorlog aren't a problem, right?
What do you think?

from laravel-bridge.

mnapoli avatar mnapoli commented on May 30, 2024

Right, that makes sense. However that sounds fragile to me: new versions of Laravel could very well rename single to something else for example.

I would love to find a solution that's a bit more reliable for the future, but I'm not sure what/how 🤔

from laravel-bridge.

bkuhl avatar bkuhl commented on May 30, 2024

As one who also uses Bugsnag and is looking to use this project in production, I'd rather accept the risk of the filesystem being implemented in a Laravel upgrade where my radar is up for potential issues than sacrifice Bugsnag support. So I'd be a fan of just eliminating the logging file aliases.

from laravel-bridge.

JonathanGuo avatar JonathanGuo commented on May 30, 2024

The variable name $logDriver is a bit misleading. The code reads from the configuration 'logging.default', which is actually the channel name.

I think the easiest solution just set the LOG_CHANNEL environment variable to be a custom one, e.g. lambda-stack, and put only stderr and bugsnag into the channels array.

        'lambda-stack' => [
            'driver' => 'stack',
            'channels' => [
                'bugsnag',
                'stderr',
            ],
            'ignore_exceptions' => false,
        ],

from laravel-bridge.

Zakini avatar Zakini commented on May 30, 2024

Just got stung by this issue while trying to add Flare to the stack log channel.

One solution might be to add a new log channel named serverless to the logging config, then change the code snippet in the OP to always set the default logging channel to serverless. By default that could only include the stderr driver, but users could add whatever other drivers they want as well. The docs would need to point this out and mention that channels that expect access to a filesystem shouldn't be used.

In any case, this issue definitely needs mentioning in the docs.

from laravel-bridge.

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.