Skip to content

Commit

Permalink
feat: Added Additional Logging Methods to Tasks Manager
Browse files Browse the repository at this point in the history
  • Loading branch information
usernane committed Jul 1, 2024
1 parent 5cf44a9 commit afc9b46
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/tasks/Fail1TestTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace app\tasks;

use webfiori\framework\scheduler\AbstractTask;
use webfiori\framework\scheduler\TasksManager;
/**
* A background process which was created using the command "create".
*
Expand Down Expand Up @@ -40,12 +41,14 @@ public function afterExec() {
* Execute the process.
*/
public function execute() {
TasksManager::logInfo('Task '.$this->getTaskName().' Is executing...');
return false;
}
/**
* Execute a set of instructions when the job failed to complete without errors.
*/
public function onFail() {
TasksManager::logErr('Task '.$this->getTaskName().' Failed.');
}
/**
* Execute a set of instructions when the job completed without errors.
Expand Down
2 changes: 2 additions & 0 deletions app/tasks/SuccessTestEveryMinute.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace app\tasks;

use webfiori\framework\scheduler\AbstractTask;
use webfiori\framework\scheduler\TasksManager;
/**
* A background process which was created using the command "create".
*
Expand Down Expand Up @@ -49,6 +50,7 @@ public function afterExec() {
* Execute the process.
*/
public function execute() {
TasksManager::logErr('Task '.$this->getTaskName().' Successfully completed.');
//TODO: Write the code that represents the process.
}
/**
Expand Down
2 changes: 2 additions & 0 deletions tests/webfiori/framework/test/cli/SchedulerCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ public function test04() {
"Forcing task 'Fail 1' to execute...\n",
"Active task: \"Fail 1\" ...\n",
"Calling the method app\\tasks\Fail1TestTask::execute()\n",
"Info: Task Fail 1 Is executing...\n",
"Calling the method app\\tasks\Fail1TestTask::onFail()\n",
"Error: Task Fail 1 Failed.\n",
"Calling the method app\\tasks\Fail1TestTask::afterExec()\n",
"Check finished.\n",
"Total number of tasks: 5\n",
Expand Down

0 comments on commit afc9b46

Please sign in to comment.