<commit_before>package util

import (
	"fmt"
	"log"
	"os"
	"strconv"
	"strings"
)

const prefix = "busl"
const defaultDomain = "development"

func init() {
	log.SetPrefix(fmt.Sprintf("busl source=%s pid=%v ", buslSource(envOrDefaultString("DOMAIN", defaultDomain)), os.Getpid()))
	log.SetFlags(0)
}

func envOrDefaultString(envvar, envdefault string) string {
	var v string
	if e := os.Getenv(envvar); e != "" {
		v = e
	} else {
		v = envdefault
	}

	return v
}

func environment(domain string) string {
	if domain == defaultDomain {
		return domain
	}

	// reverse the domain
	s := strings.Split(domain, ".")
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		s[i], s[j] = s[j], s[i]
	}
	s = append(s, prefix, strconv.Itoa(os.Getpid()))
	return strings.Join(s, ".")
}

func buslSource(domain string) string {
	parts := []string{environment(domain)}
	return strings.Join(parts, ".")
}
<commit_msg>pid isn't very useful here, since we gracefully restart, the pid can change<commit_after>package util

import (
	"fmt"
	"log"
	"os"
	"strings"
)

const prefix = "busl"
const defaultDomain = "development"

func init() {
	log.SetPrefix(fmt.Sprintf("busl source=%s pid=%v ", buslSource(envOrDefaultString("DOMAIN", defaultDomain)), os.Getpid()))
	log.SetFlags(0)
}

func envOrDefaultString(envvar, envdefault string) string {
	var v string
	if e := os.Getenv(envvar); e != "" {
		v = e
	} else {
		v = envdefault
	}

	return v
}

func environment(domain string) string {
	if domain == defaultDomain {
		return domain
	}

	// reverse the domain
	s := strings.Split(domain, ".")
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		s[i], s[j] = s[j], s[i]
	}
	s = append(s, prefix)
	return strings.Join(s, ".")
}

func buslSource(domain string) string {
	parts := []string{environment(domain)}
	return strings.Join(parts, ".")
}

{'fraction_non_alphanumeric': 0.16885964912280702, 'fraction_numerical': 0.005482456140350877, 'mean_word_length': 4.013736263736264, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6293367', 'n_tokens_mistral': 712, 'n_tokens_neox': 694, 'n_words': 180}