-
Notifications
You must be signed in to change notification settings - Fork 119
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
[LOG] Improve logs wording, add classname in log files #1103
Conversation
M0rgan01
commented
Jan 3, 2025
Questions | Answers |
---|---|
Description? | Improve logs wording, add classname in log files |
Type? | improvement |
BC breaks? | no |
Deprecations? | no |
Fixed ticket? | - |
Sponsor company | - |
How to test? | - |
ac5fe41
to
57a6791
Compare
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.
A small typo otherwise everything is good, thank you!
57a6791
to
5230298
Compare
With classname (with dev branch) in seconde
Average: 69.76 With classname in seconde
Average: 69.96 test conditions: I use Total logs for 1 update: 30 000 |
… into M0rgan01-improve-log-wording
I've created a task that only calls the logger in a reasonable way: class Test extends AbstractTask
{
const TASK_TYPE = TaskType::TASK_TYPE_UPDATE;
/**
* @throws Exception
*/
public function run(): int
{
for ($i = 0 ; $i < 450 ; ++$i) {
$this->logger->info($this->translator->trans(
'Logger called'
));
}
$this->next = TaskName::TASK_UPDATE_COMPLETE;
return ExitCode::SUCCESS;
}
} It takes 12 on the When we profile it, getting the caller is taking ~13% of the script execution time and is flagged by Blackfire as an intensive node. And when focusing on this method on particular: |
classes/Log/Logger.php
Outdated
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); | ||
|
||
foreach ($trace as $frame) { | ||
if ( | ||
isset($frame['class']) && | ||
!is_subclass_of($frame['class'], self::class) && | ||
$frame['class'] !== self::class | ||
) { |
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.
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); | |
foreach ($trace as $frame) { | |
if ( | |
isset($frame['class']) && | |
!is_subclass_of($frame['class'], self::class) && | |
$frame['class'] !== self::class | |
) { | |
// We don't need the whole stack. The 5th level is enough to get | |
// the called of the logger but we keep a buffer in case it goes deeper. | |
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 8); | |
foreach ($trace as $frame) { | |
if ( | |
isset($frame['class']) && | |
strpos($frame['class'], __NAMESPACE__) === false | |
) { |
d97390e
to
20699cb
Compare
Quality Gate passedIssues Measures |
Caller class is properly reported in the log file. |