-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: Logger #10
feat: Logger #10
Conversation
Seems good! Would you be up to writing a short documentation page of how logging can be used as well? It could be as a comment on this PR, but it would help me grasp the implications for end-users, and not just judge this PR from a technical POV :) |
Pull Request Test Coverage Report for Build 9134732003Details
💛 - Coveralls |
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.
I'm actually going to merge this and make some changes myself, because I need this logger to work on some more stuff 😁 I left some comments so that you know what I intend to change, and we can further finetune it down the line :)
/** @var LogChannel $channel */ | ||
$channel = $this->container->get($channelName); | ||
|
||
$config = $this->logConfig->channelsConfig[$channelName] ?? []; |
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.
This config should be an object with typed properties, not an array
* | ||
* @return array<int, HandlerInterface>|HandlerInterface | ||
*/ | ||
public function handler(Level $level, array $config): array|HandlerInterface; |
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.
I think it'd be better to call this method getHandlers
and always have it return an array, for simplicity. Same for getProcessors
/** @var LogChannel[] */ | ||
public array $channels = [], | ||
/** @var array<class-string<LogChannel>, array|string> */ | ||
public array $channelsConfig = [], |
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.
I feel like we need to improve channel config
|
||
$config = new LogConfig( | ||
channelsConfig: [ | ||
AppendLogChannel::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.
What if we had an array of channels
, with instances of channels that we configured?
new LogConfig(
channels: [
new AppendLogChannel(path: $filePath)
],
)
That way we'd combine channel
and channelConfig
into one.
Adds basic support for logs.
Needs some cleanup but would appreciate any feedback :)