81 public function emit( $text ) : void {
83 if ( $this->prefix !== false ) {
84 $text = preg_replace(
'/^/m', $this->prefix .
' ', $text );
86 if ( strlen( $text ) > self::MAX_PAYLOAD_SIZE - 1 ) {
87 $text = substr( $text, 0, self::MAX_PAYLOAD_SIZE - 1 );
90 if ( substr( $text, -1 ) !=
"\n" ) {
93 } elseif ( strlen( $text ) > self::MAX_PAYLOAD_SIZE ) {
94 $text = substr( $text, 0, self::MAX_PAYLOAD_SIZE );
97 $sock = socket_create( $this->domain, SOCK_DGRAM, SOL_UDP );
102 socket_sendto( $sock, $text, strlen( $text ), 0, $this->host, $this->port );
103 socket_close( $sock );