Set Revision Log Message Programmatically

As lazy we humans are we tent to forget the Revision log message and move on but that us bad for our system and it is a good habit to save data about changes you have done so this is how you can Set Revision Log Message Programmatically 


use Drupal\node\NodeInterface;

use Drupal\Core\Entity\EntityInterface;



* Implements hook_entity_presave().


function custom_module_entity_presave(EntityInterface $entity) {

 switch ($entity->bundle()) {

   case 'page_index':

     if ($entity instanceof NodeInterface) {

       $message = '';

       $entity->revision_log->value = $message;