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

[feature request] ability to use a callable expression as a output parameter #58

Open
wujekbogdan opened this issue May 24, 2016 · 2 comments

Comments

@wujekbogdan
Copy link

I'd like to use an error logger (like Monolog) to log errors. So it would be great if the output parameter accepted a callable argument (like closure).

@jeckel
Copy link

jeckel commented Nov 4, 2016

Or at least a PSR-3 logger

@garethellis36
Copy link
Contributor

I'd find this useful too. I've looked at the source code and I think the major issue is serialization. The callable would need to be serialized (not an issue as the library already has a dependency on the superclosure library), but so would any dependency of the callable. Taking Monolog for example, a StreamHandler cannot be serialized.

The only thing I can think of at the moment is to add an interface like Psr3LoggerFactory that the callable has to return. e.g

`output` => function () {
  return new class implements Psr3LoggerFactory {
    public function createLogger(): LoggerInterface {
       // return a PSR3 logger, e.g. Monolog
    }
  }
}

Then background job would do something like

if (is_callable($config["output"])) {
 $logger = $config["output"]();
} else {
  // log to file
}

Thoughts? cc @hellogerard

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

No branches or pull requests

4 participants