-
Notifications
You must be signed in to change notification settings - Fork 11.8k
[12.x] Allow specifying that context should live under log's context
#58309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,8 @@ | |
|
|
||
| namespace Illuminate\Support\Facades; | ||
|
|
||
| use Illuminate\Log\Context\Repository; | ||
|
|
||
| /** | ||
| * @method static bool has(string $key) | ||
| * @method static bool missing(string $key) | ||
|
|
@@ -17,30 +19,30 @@ | |
| * @method static array onlyHidden(array $keys) | ||
| * @method static array except(array $keys) | ||
| * @method static array exceptHidden(array $keys) | ||
| * @method static \Illuminate\Log\Context\Repository add(string|array $key, mixed $value = null) | ||
| * @method static \Illuminate\Log\Context\Repository addHidden(string|array $key, mixed $value = null) | ||
| * @method static Repository add(string|array $key, mixed $value = null) | ||
| * @method static Repository addHidden(string|array $key, mixed $value = null) | ||
| * @method static mixed remember(string $key, mixed $value) | ||
| * @method static mixed rememberHidden(string $key, mixed $value) | ||
| * @method static \Illuminate\Log\Context\Repository forget(string|array $key) | ||
| * @method static \Illuminate\Log\Context\Repository forgetHidden(string|array $key) | ||
| * @method static \Illuminate\Log\Context\Repository addIf(string $key, mixed $value) | ||
| * @method static \Illuminate\Log\Context\Repository addHiddenIf(string $key, mixed $value) | ||
| * @method static \Illuminate\Log\Context\Repository push(string $key, mixed ...$values) | ||
| * @method static Repository forget(string|array $key) | ||
| * @method static Repository forgetHidden(string|array $key) | ||
| * @method static Repository addIf(string $key, mixed $value) | ||
| * @method static Repository addHiddenIf(string $key, mixed $value) | ||
| * @method static Repository push(string $key, mixed ...$values) | ||
| * @method static mixed pop(string $key) | ||
| * @method static \Illuminate\Log\Context\Repository pushHidden(string $key, mixed ...$values) | ||
| * @method static Repository pushHidden(string $key, mixed ...$values) | ||
| * @method static mixed popHidden(string $key) | ||
| * @method static \Illuminate\Log\Context\Repository increment(string $key, int $amount = 1) | ||
| * @method static \Illuminate\Log\Context\Repository decrement(string $key, int $amount = 1) | ||
| * @method static Repository increment(string $key, int $amount = 1) | ||
| * @method static Repository decrement(string $key, int $amount = 1) | ||
| * @method static bool stackContains(string $key, mixed $value, bool $strict = false) | ||
| * @method static bool hiddenStackContains(string $key, mixed $value, bool $strict = false) | ||
| * @method static mixed scope(callable $callback, array $data = [], array $hidden = []) | ||
| * @method static bool isEmpty() | ||
| * @method static \Illuminate\Log\Context\Repository dehydrating(callable $callback) | ||
| * @method static \Illuminate\Log\Context\Repository hydrated(callable $callback) | ||
| * @method static \Illuminate\Log\Context\Repository handleUnserializeExceptionsUsing(callable|null $callback) | ||
| * @method static \Illuminate\Log\Context\Repository flush() | ||
| * @method static \Illuminate\Log\Context\Repository|mixed when(\Closure|mixed|null $value = null, callable|null $callback = null, callable|null $default = null) | ||
| * @method static \Illuminate\Log\Context\Repository|mixed unless(\Closure|mixed|null $value = null, callable|null $callback = null, callable|null $default = null) | ||
| * @method static Repository dehydrating(callable $callback) | ||
| * @method static Repository hydrated(callable $callback) | ||
| * @method static Repository handleUnserializeExceptionsUsing(callable|null $callback) | ||
| * @method static Repository flush() | ||
| * @method static Repository|mixed when(\Closure|mixed|null $value = null, callable|null $callback = null, callable|null $default = null) | ||
| * @method static Repository|mixed unless(\Closure|mixed|null $value = null, callable|null $callback = null, callable|null $default = null) | ||
| * @method static void macro(string $name, object|callable $macro) | ||
| * @method static void mixin(object $mixin, bool $replace = true) | ||
| * @method static bool hasMacro(string $name) | ||
|
|
@@ -58,6 +60,22 @@ class Context extends Facade | |
| */ | ||
| protected static function getFacadeAccessor() | ||
| { | ||
| return \Illuminate\Log\Context\Repository::class; | ||
| return Repository::class; | ||
| } | ||
|
|
||
| /** | ||
| * Write context data under the structured log's "extra" key. | ||
| */ | ||
| public static function writeContextToLogExtra(): void | ||
| { | ||
| Repository::$writeContextTo = 'extra'; | ||
| } | ||
|
|
||
| /** | ||
| * Write context data under the structured log's "context" key. | ||
| */ | ||
| public static function writeContextToLogContext(): void | ||
| { | ||
| Repository::$writeContextTo = 'context'; | ||
|
Comment on lines
+69
to
+79
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can these not live on the context repository class? |
||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this not be an instance property?