protected function checkLength($str, $max_length = '', $type = 'packet')
    {
        $max_length = $max_length ? $max_length : $this->max_length;
        if ($max_length == -1) {
            return $str;
        }

        $strlen = strlen($str);
        if ($strlen > $max_length) {
            throw new \Exception("Syslog " . $type . " is > " . $max_length . " (" . $strlen . ") in length and will be truncated.  Original str is: " . $str, E_USER_WARNING);
            return substr($str, 0, $max_length);
        }

        return $str;
    }