[FEATURE] Use "keyword arguments" for the CloudWatch constructor
jdufresne opened this issue · comments
Is your feature request related to a problem? Please describe.
I recently wanted to change the $createGroup
argument. This is the last argument in a long-ish list of arguments. To solve this, I had to copy and paste all the default arguments when instantiating the handler. It now looks like:
$handler = new CloudWatch(
$client,
$log_group,
$stream_name,
14, // $retention (default)
10000, // $batchSize (default)
[], // $tags (default)
Logger::DEBUG, // $level (default)
true, // $bubble (default)
false, // $createGroup
);
If the library changes the default value, my instantiation could easily go out of sync.
The values themselves are opaque (what is 14?) requiring me to add multiple inline comments.
Describe the solution you'd like
Allow passing an array of keywords to the constructor. For example:
$handler = new CloudWatch([
'client' => $client,
'group' => $log_group,
'stream' => $stream_name,
'createGroup' => false,
]);
This is self documenting and allows omitting default values.
This could be backwards compatible by checking the number and type of arguments and then acting accordingly.
Hi! Good idea! Can you make a PR for this?
OK, but what if I want the retention to be infinite?
In the actual code, there is no way to set $retention to null because it has a default >:/