Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted January 22, 20169 yr I'm trying to investigate frequent downtime periods that happens fairly daily, but still not with a clear interval between each time. In doing that I'm trying to now look over whether any of the tasks cause this. The problem I have with that is that there are no log entries for when each task has actually been executed, so I can't see if any of the previous execution times for tasks corresponds to the times our servers tend to go down.
January 24, 20169 yr I would also like to know how to make tasks more expressive when they are run or not (i.e. logs in task log).
January 27, 20169 yr Author And you should log how long time the task spent. I've added some custom code to log this myself now in system/Task/Task.php public function runAndLog() { # HW_CUSTOM log task runnings \IPS\Log::i( LOG_NOTICE )->write( "Start to run task {$this->id}($this->key)", 'taskRunLog' ); $start = microtime( true ); $result = NULL; $error = FALSE; try { $result = $this->run(); } catch ( \IPS\Task\Exception $e ) { $result = $e->getMessage(); $error = 1; } $end_time = round( microtime( true ) - $start, 5 ); \IPS\Log::i( LOG_NOTICE )->write( "Task {$this->id}($this->key) was finished in {$end_time} seconds", 'taskRunLog' ); if ( $error !== FALSE or $result !== NULL ) { \IPS\Db::i()->insert( 'core_tasks_log', array( 'task' => $this->id, 'error' => $error, 'log' => json_encode( $result ), 'time' => time() ) ); } } But I feel you should log this information to the database table.
Archived
This topic is now archived and is closed to further replies.