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

Using other classes #75

Closed
peterlaws opened this issue Dec 4, 2015 · 8 comments
Closed

Using other classes #75

peterlaws opened this issue Dec 4, 2015 · 8 comments

Comments

@peterlaws
Copy link

Where does it say this class uses other classes? Nowhere

@onno-vos-dev
Copy link
Contributor

I'm not really sure what the issue is here? It uses: https://github.com/php-fig/log as the log interface if that's what you're wondering about?

Please explain the issue at hand here?

@peterlaws
Copy link
Author

Where does it say you need to download that, from a n00b respective, except within the About section as a link.

@onno-vos-dev
Copy link
Contributor

Composer will take care of that for you :) Just use composer install and everything will be automagically handled for you :)

@peterlaws
Copy link
Author

I don't use composer though :)

Also, what is with the 'vendor/autoload.php'? I see no such file, only the 'Logger.php' file, so had to DIY include_once in the correct order.

@onno-vos-dev
Copy link
Contributor

I'd highly suggest you start using composer in that case. It takes care of loading all the dependencies and creating the vendor/autoload.php file for you.

Composer is a pretty wide spread tool within PHP development so you're going to encounter it in other places as well so you might as well start learning. Just do some reading on: https://getcomposer.org/

@katzgrau
Copy link
Owner

katzgrau commented Dec 4, 2015

@peterlaws It's pretty common to use 3rd party packages now (in this case, it's not even a package, but an interface nearly every logging lib implements). Dependencies are no longer the exception, but the norm. That goes for nearly every other language too: ruby, python, javascript, yada yada. They each have their own packages and package managers.

If you're interested in the older, standalone version of KLogger, it's at: https://github.com/katzgrau/KLogger/releases/tag/0.2.0

@peterlaws
Copy link
Author

Why isn't this writing to the file?

function logging($level = 'DEBUG') {
  $path = '/blah/';
  $level = "Psr\Log\LogLevel::".$level;
  $options = array('dateFormat' => 'd-m-Y G:i:s.u', 'filename' => 'system.log');
  $logger = new Katzgrau\KLogger\Logger($path, $level, $options);
  $logger->error('Test');
  return $logger;
}

@katzgrau
Copy link
Owner

katzgrau commented Dec 4, 2015

There could be other reasons, but two obvious ones:

  • The $level variable is just a string containing a namespace. You would at least need to wrap it like: $level = constant("Psr\Log\LogLevel::".$level);
  • Does the directory /blah/ actually exist? Seems unlikely, unless it was just for example purposes.

By the way, that first mistake should have generated at least a PHP notice..

Anyway, I don't want to be rude, but these aren't KLogger issues - just issues with knowledge of PHP. Questions like this are probably better addressed on a PHP forum or IRC chat.

Repository owner locked and limited conversation to collaborators Dec 4, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants