code: def _write_history(self, pfx, hdu, linechar=60, indentchar=2):
          
          channel = self.fv.get_channel(self.chname)
          if channel is None:
              return
  
          history_plgname = 'ChangeHistory'
          try:
              history_obj = self.fv.gpmon.getPlugin(history_plgname)
          except Exception:
              self.logger.error(
                  '{0} plugin is not loaded. No HISTORY will be written to '
                  '{1}.'.format(history_plgname, pfx))
              return
  
          if channel.name not in history_obj.name_dict:
              self.logger.error(
                  '{0} channel not found in {1}. No HISTORY will be written to '
                  '{2}.'.format(channel.name, history_plgname, pfx))
              return
  
          file_dict = history_obj.name_dict[channel.name]
          chistory = []
          ind = ' ' * indentchar
  
          # NOTE: List comprehension too slow!
          for key in file_dict:
              if not key.startswith(pfx):
                  continue
              for bnch in file_dict[key].values():
                  chistory.append('{0} {1}'.format(bnch.MODIFIED, bnch.DESCRIP))
  
          # Add each HISTORY prettily into header, sorted by timestamp
          for s in sorted(chistory):
              for i in range(0, len(s), linechar):
                  subs = s[i:i + linechar]
                  if i > 0:
                      subs = ind + subs.lstrip()
                  hdu.header.add_history(subs)
docs: Write change history to given HDU header.
          Limit each HISTORY line to given number of characters.
          Subsequent lines of the same history will be indented.