<commit_before>package main

import (
	"github.com/matrix-org/dendrite/clientapi/routing"
	"net/http"
	"os"

	log "github.com/Sirupsen/logrus"
)

func main() {
	bindAddr := os.Getenv("BIND_ADDRESS")
	if bindAddr == "" {
		log.Panic("No BIND_ADDRESS environment variable found.")
	}
	log.Info("Starting clientapi")
	routing.Setup(http.DefaultServeMux, http.DefaultClient)
	log.Fatal(http.ListenAndServe(bindAddr, nil))
}
<commit_msg>Implement logging to file via dugong (#12)<commit_after>package main

import (
	"net/http"
	"os"
	"path/filepath"

	"github.com/matrix-org/dendrite/clientapi/routing"

	log "github.com/Sirupsen/logrus"
	"github.com/matrix-org/dugong"
)

func setupLogging(logDir string) {
	_ = os.Mkdir(logDir, os.ModePerm)
	log.AddHook(dugong.NewFSHook(
		filepath.Join(logDir, "info.log"),
		filepath.Join(logDir, "warn.log"),
		filepath.Join(logDir, "error.log"),
		&log.TextFormatter{
			TimestampFormat:  "2006-01-02 15:04:05.000000",
			DisableColors:    true,
			DisableTimestamp: false,
			DisableSorting:   false,
		}, &dugong.DailyRotationSchedule{GZip: true},
	))
}

func main() {
	bindAddr := os.Getenv("BIND_ADDRESS")
	if bindAddr == "" {
		log.Panic("No BIND_ADDRESS environment variable found.")
	}
	logDir := os.Getenv("LOG_DIR")
	if logDir != "" {
		setupLogging(logDir)
	}
	log.Info("Starting clientapi")
	routing.Setup(http.DefaultServeMux, http.DefaultClient)
	log.Fatal(http.ListenAndServe(bindAddr, nil))
}

{'fraction_non_alphanumeric': 0.1530470914127424, 'fraction_numerical': 0.015235457063711912, 'mean_word_length': 4.873983739837398, 'pattern_counts': {'":': 0, '<': 3, '<?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': '370909', 'n_tokens_mistral': 595, 'n_tokens_neox': 558, 'n_words': 87}