have you looked at pipelines?
You could pass the taskname through the classes specified in the pipeline.
Hi,
I'm creating a backend Laravel app that will run a whole bunch of tasks on a schedule. Part of what I'm doing is logging the tasks and it's child actions.
For example, we have a task to:
This task will run through a lot of single functions from different classes. In each one of these functions, I have a logger that logs informational data. For example, log how many files were found on the sourceHost. The logs are stored, and if we ever want some insight into what happened, we can look back at the logs.
What I'm trying to achieve, is that when the task kicks off, it sets a variable with $taskName = 'getOrdersFile' and then throughout the process, have that $taskName variable available so that I can add it to my log entries.
I know that I can keep on passing that variable to every class and function, but I am looking for a way to define this at the begining and then have it available all throughout the execution of this process.
I don't want to just set an ENV, because we could ne running multiple processes at the same time.
SO what I'm looking to do is to wrap each process and allow each process to have it's own definition $taskName.
I know I may be asking a broad question, I'm not asking for you to write this out for me, I'm a newbie in Laravel and I'm looking for directions or pointers.
@lakewoodtrees use the app container?
$app()->bind('taskName', function(){
return 'getOrdersFile';
});
then you can use
app('taskName');
Whether this would work depends on how you start the tasks and if they might share the same process from one set of tasks to another.
Please or to participate in this conversation.