<commit_before>// This file is part of graze/golang-service
//
// Copyright (c) 2016 Nature Delivered Ltd. <https://www.graze.com>
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
//
// license: https://github.com/graze/golang-service/blob/master/LICENSE
// link:    https://github.com/graze/golang-service

package handlers

import (
    "testing"
    "github.com/graze/golang-service/nettest"
    "github.com/stretchr/testify/assert"
    "net"
    "net/http"
    "net/http/httptest"
    "os"
)

func TestRSyslogLogging(t *testing.T) {
    done := make(chan string)
    addr, sock, srvWg := nettest.CreateServer(t, "udp", "localhost:", done)
    defer srvWg.Wait()
    defer os.Remove(addr.String())
    defer sock.Close()

    host, port, err := net.SplitHostPort(addr.String())
    if err != nil {
        t.Fatal(err)
    }
    os.Setenv("SYSLOG_NETWORK", "udp")
    os.Setenv("SYSLOG_HOST", host)
    os.Setenv("SYSLOG_PORT", port)
    os.Setenv("SYSLOG_APPLICATION", "service.application")

    handler := SyslogHandler(okHandler)

    // A typical request with an OK response
    req := newRequest("GET", "http://example.com/")

    rec := httptest.NewRecorder()
    handler.ServeHTTP(rec, req)

    assert.Equal(t, http.StatusOK, rec.Code)

    assert.Regexp(t, `<176>[0-9\-]+T[0-9:]+Z \w+ service\.application\[\d+\]:  - - \[\d{2}\/\w+\/\d{4}:\d{2}:\d{2}:\d{2} [\+\-]+\d+\] "GET \/ HTTP\/1\.1" 200 \d+ "" ""`, <-done)
}
<commit_msg>update default priority<commit_after>// This file is part of graze/golang-service
//
// Copyright (c) 2016 Nature Delivered Ltd. <https://www.graze.com>
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
//
// license: https://github.com/graze/golang-service/blob/master/LICENSE
// link:    https://github.com/graze/golang-service

package handlers

import (
    "testing"
    "github.com/graze/golang-service/nettest"
    "github.com/stretchr/testify/assert"
    "net"
    "net/http"
    "net/http/httptest"
    "os"
)

func TestRSyslogLogging(t *testing.T) {
    done := make(chan string)
    addr, sock, srvWg := nettest.CreateServer(t, "udp", "localhost:", done)
    defer srvWg.Wait()
    defer os.Remove(addr.String())
    defer sock.Close()

    host, port, err := net.SplitHostPort(addr.String())
    if err != nil {
        t.Fatal(err)
    }
    os.Setenv("SYSLOG_NETWORK", "udp")
    os.Setenv("SYSLOG_HOST", host)
    os.Setenv("SYSLOG_PORT", port)
    os.Setenv("SYSLOG_APPLICATION", "service.application")

    handler := SyslogHandler(okHandler)

    // A typical request with an OK response
    req := newRequest("GET", "http://example.com/")

    rec := httptest.NewRecorder()
    handler.ServeHTTP(rec, req)

    assert.Equal(t, http.StatusOK, rec.Code)

    assert.Regexp(t, `<181>[0-9\-]+T[0-9:]+Z \w+ service\.application\[\d+\]:  - - \[\d{2}\/\w+\/\d{4}:\d{2}:\d{2}:\d{2} [\+\-]+\d+\] "GET \/ HTTP\/1\.1" 200 \d+ "" ""`, <-done)
}

{'fraction_non_alphanumeric': 0.1879502292075966, 'fraction_numerical': 0.0137524557956778, 'mean_word_length': 3.0144546649145862, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 6, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3064555', 'n_tokens_mistral': 1167, 'n_tokens_neox': 1100, 'n_words': 226}