-
-
Notifications
You must be signed in to change notification settings - Fork 190
FEATURE: Add fromClassAndMethodName() to LogEnvironment #3419
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
base: 8.3
Are you sure you want to change the base?
Conversation
This does some code cleanup and adds a new method `fromClassAndMethodName($className, $methodName)` to the `LogEnvironment`.
It be used like this:
LogEnvironment::fromClassAndMethodName(__CLASS__, __METHOD__)
and will return useful data – as opposed to `LogEnvironment::fromMethodName(__METHOD__)`, which only works for static methods (`SomeClass::someMethod` or closures).
| * under the key FLOW_LOG_ENVIRONMENT to be set as part of the | ||
| * additional data in an log method call. | ||
| */ | ||
| public static function fromClassAndMethodName(string $className, string $methodName): array |
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.
What if we also allow passing an object instead of the class name? That way you could just pass $this in most cases.
public static function fromClassAndMethodName(string|object $class, string $methodName): array
{
$className = is_object($class) ? get_class($object) : $className;
...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.
Does that make it easier to use? You can even use $this::class if you like…
|
Why is this a task and not a new (tiny) feature? |
So I can sneak it into 8.3… 😎 |
markusguenther
left a comment
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.
Fine, thank you @kdambekalns
It is a tiny tiny feature, but not sure if we should merge it in 8.3 or better 8.4 or so
This does some code cleanup and adds a new method
fromClassAndMethodName($className, $methodName)to theLogEnvironment.It be used like this:
and will return useful data – as opposed to
LogEnvironment::fromMethodName(__METHOD__), which only works for static methods (SomeClass::someMethodor closures).Checklist
FEATURE|TASK|BUGFIX!!!and have upgrade-instructions