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

Warning: log() expects parameter 1 to be float, string given #30

Closed
adamwinn opened this issue Sep 25, 2017 · 1 comment
Closed

Warning: log() expects parameter 1 to be float, string given #30

adamwinn opened this issue Sep 25, 2017 · 1 comment

Comments

@adamwinn
Copy link

I was following this example

$scheduler->php('script.php')->then(function ($output) {
    log('Job executed!');
}, true);

and I got Warning: log() expects parameter 1 to be float, string given

@peppeocchi
Copy link
Owner

@adamwinn sorry for the confusion but that example is not a working example, it's there just to show that you can do whatever you want with the output of your script after is being executed.

The log function should be your own implementation of a logging system.

I use Seldaek/monolog in almost every project, it's easy to use and a simple implementation will look like

<?php

require_once __DIR__.'/vendor/autoload.php';

use GO\Scheduler;

use Monolog\Logger;
use Monolog\Handler\StreamHandler;

$log = new Logger('scheduler-logger');
$log->pushHandler(new StreamHandler('path/to/your.log', Logger::WARNING));

$scheduler = new Scheduler();

$scheduler->php('script.php')->then(function ($output) use ($log) {
    $log->info('Job executed!');
}, true);

$scheduler->run();

TL;DR

V1 of this Scheduler has a built in functionality for logging, in V2 that was removed, I added that example to provide an alternative on how to implement your custom log.

peppeocchi added a commit that referenced this issue Sep 25, 2017
peppeocchi pushed a commit that referenced this issue Oct 8, 2017
* Updated example

Ref #30

* Add before run method

* Add unit test to before function and remove job instance parameter
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

2 participants