public static function error_log_wrap($message)
  {
    // msglen is the remain length of the message that needs to be written.
    $msglen=strlen($message);
    $i=0;
    while($msglen>0){
      if($msglen>8000){
        // the remaining message that needs to be written is still longer than 8000 bytes
        // so error_log only a chunk (start at offset: number of itereations * 8000)
        error_log(substr($message,$i*8000,8000));
        $msglen=$msglen-8000;
      }else{
        // less than 8000 bytes left, write the remainder (end)
        error_log(substr($message,$i*8000));
        $msglen=0;
      }
      $i++;
    }
  }