Skip to content
This repository has been archived by the owner on Feb 15, 2023. It is now read-only.

Commit

Permalink
Do not override log settings now
Browse files Browse the repository at this point in the history
  • Loading branch information
bubba-h57 committed Feb 27, 2019
1 parent 8e10c7e commit cb1bdb8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 31 deletions.
1 change: 1 addition & 0 deletions config/bref.php
Expand Up @@ -72,6 +72,7 @@
'BREF_LAMBDA_ENV', // True
'LOG_CHANNEL', // stderr (ensures everything logs into cloudwatch)
'CACHE_DRIVER', // file (because, what else really makes sense?
'SESSION_DRIVER', // Array
],
],
];
2 changes: 2 additions & 0 deletions config/cloudformation.yaml
Expand Up @@ -7,10 +7,12 @@ Globals:
Environment:
Variables:
# Laravel environment variables
# @todo: Should probably make these configurable in config/bref.php file
APP_STORAGE: '/tmp' # The only thing we can write to in Lambda
BREF_LAMBDA_ENV: true # Make it easy to determine we are running in Lambda. Use `runningInLambda()` helper.
LOG_CHANNEL: stderr # Log to stderr so that everything goes to cloudwatch.
CACHE_DRIVER: file
SESSION_DRIVER: array

Resources:
Website:
Expand Down
31 changes: 0 additions & 31 deletions src/Providers/Bref.php
Expand Up @@ -70,7 +70,6 @@ public function boot(): void
if (runningInLambda()) {
$this->setupStorage();
$this->setupSessionDriver();
$this->setupLogStack();
}
$this->handlePublishing();

Expand Down Expand Up @@ -122,36 +121,6 @@ public function setupSessionDriver(): void
}
}

/**
* At this point, the default single and daily logs will
* log to `storage_path('logs/laravel.log')` and we have that
* aimed at /tmp already. But that doesn't do anyone any good.
* We expect the logs to all go to STDERR so that lambda just
* automatically logs them to CloudWatch.
*/
public function setupLogStack(): void
{
// If you don't want me messing with this, or you already use stderr, we're done
if (env('LEAVE_MY_LOGS_ALONE') || Config::get('logging.default') === 'stderr') {
return;
}

// Ok, I will inject stderr into whatever you are doing.
if (Config::get('logging.default') === 'stack') {
// Good, you are already using the stack.
$channels = Config::get('logging.channels.stack.channels');
if (! in_array('stderr', $channels)) {
$channels[] = 'stderr';
}
} else {
// Just gonna setup a stack log channel for you here.
$channels = ['stderr', Config::get('logging.default')];
}

Config::set('logging.channels.stack.channels', $channels);
Config::set('logging.default', 'stack');
}

/**
* Publish any artifacts to laravel user space
*/
Expand Down

0 comments on commit cb1bdb8

Please sign in to comment.