Skip to content
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

throw exception when parameters object is null #58

Closed
vanjor opened this issue Jun 7, 2015 · 4 comments
Closed

throw exception when parameters object is null #58

vanjor opened this issue Jun 7, 2015 · 4 comments

Comments

@vanjor
Copy link

vanjor commented Jun 7, 2015

Argument 2 passed to Psr\Log\AbstractLogger::info() must be of the type array, null given

when calling $logger->info("raise the log", null);

@onno-vos-dev
Copy link
Contributor

@vanjor What exactly is your point?

The call is quite clear, it must take an array... Whether or not that functionality should be expanded to include other types of context, is a valid discussion in my opinion but you don't raise such point.

Adding null as a context won't add anything to your logfile and no matter what type of context we would allow, it would always look kinda odd.

@katzgrau
Copy link
Owner

katzgrau commented Jun 8, 2015

Agreed w/ @onno-vos-dev

If you've got a concrete idea of what/how you think it should work, submit a PR and we'll have a look over.

@katzgrau katzgrau closed this as completed Jun 8, 2015
@onno-vos-dev
Copy link
Contributor

(Sorry to comment on a closed Issue @katzgrau )

Just to add to this:

If we would like to include other forms of context, it would automatically mean we would deviate from the PSR-3 LoggerInterface as that only allows for $context to be of type array. Again, whether or not this is the best solution, I think is worth thinking about but breaking the LoggerInterface in favor of KLogger does not sound like a great idea to me.
See: LoggerInterface Context

My final $0,02:
If you need more context to be added to your log, you can always go as followed (which is what we use internally if we want really verbose logs).

$logger->log(LogLevel::DEBUG, 'Your request failed. The request you sent was: '.json_encode($request_data));

@vanjor
Copy link
Author

vanjor commented Jun 9, 2015

Thanks to both.

Actually I does not expect logging function raise the exception, for PHP is a weak type as many function expected to return array, but return null at some case.

accept @onno-vos-dev suggest,though this substituted way is a little bit verbos:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants