<commit_before>package main

import (
	"bufio"
	"bytes"
	"encoding/json"
	"flag"
	"fmt"
	"io"
	"io/ioutil"
	"log"
	"net"
	"net/http"
	"os"
	"regexp"
	"sync"
	"time"

	"gopkg.in/yaml.v2"
)

type Config struct {
	Name        string   `toml:"name"`
	Type        string   `toml:"type"`
	Description string   `yaml:"description"`
	Timeout     int      `toml:"timeout"`
	URL         []string `toml:"url"`
	state       []string
	last        time.Time
}

type Service struct {
	URL     string
	Timeout int
}

type URL struct {
	Name  string `json:"name"`
	State string `json:"state"`
	URL   string `json:"url"`
}

type Site struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	URLs        []*URL `json:"children"`
}

type Sites struct {
	TopLevel string  `json:"name"`
	Sites    []*Site `json:"children"`
}

type Status interface {
	Check(Service) (bool, error)
}

var check map[string]Status

type server struct {
	configfile  string
	lastconfig  time.Time
	htmlfile    string
	lasthtml    time.Time
	cfg         []*Config
	sites       Sites
	html        []byte
	next_status time.Time
	last_status time.Time
	timer_epoch int
	timeout     int
	epoch       int
	sync.Mutex
}

const (
	Wait   = true
	NoWait = false
)

func (s *server) parseConfig() error {
	s.Lock()
	defer s.Unlock()

	fi, err := os.Stat(s.configfile)
	if err != nil {
		return err
	}

	if s.lastconfig.After(fi.ModTime()) {
		return nil
	}

	s.epoch += 1

	data, err := ioutil.ReadFile(s.configfile)
	if err != nil {
		return err
	}

	err = yaml.Unmarshal(data, &s.cfg)
	if err != nil {
		return err
	}
<commit_msg>log when reading the config file<commit_after>package main

import (
	"bufio"
	"bytes"
	"encoding/json"
	"flag"
	"fmt"
	"io"
	"io/ioutil"
	"log"
	"net"
	"net/http"
	"os"
	"regexp"
	"sync"
	"time"

	"gopkg.in/yaml.v2"
)

type Config struct {
	Name        string   `toml:"name"`
	Type        string   `toml:"type"`
	Description string   `yaml:"description"`
	Timeout     int      `toml:"timeout"`
	URL         []string `toml:"url"`
	state       []string
	last        time.Time
}

type Service struct {
	URL     string
	Timeout int
}

type URL struct {
	Name  string `json:"name"`
	State string `json:"state"`
	URL   string `json:"url"`
}

type Site struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	URLs        []*URL `json:"children"`
}

type Sites struct {
	TopLevel string  `json:"name"`
	Sites    []*Site `json:"children"`
}

type Status interface {
	Check(Service) (bool, error)
}

var check map[string]Status

type server struct {
	configfile  string
	lastconfig  time.Time
	htmlfile    string
	lasthtml    time.Time
	cfg         []*Config
	sites       Sites
	html        []byte
	next_status time.Time
	last_status time.Time
	timer_epoch int
	timeout     int
	epoch       int
	sync.Mutex
}

const (
	Wait   = true
	NoWait = false
)

func (s *server) parseConfig() error {
	s.Lock()
	defer s.Unlock()

	fi, err := os.Stat(s.configfile)
	if err != nil {
		return err
	}

	if s.lastconfig.After(fi.ModTime()) {
		return nil
	}

	s.epoch += 1

	log.Println("reading", s.configfile)

	data, err := ioutil.ReadFile(s.configfile)
	if err != nil {
		return err
	}

	err = yaml.Unmarshal(data, &s.cfg)
	if err != nil {
		return err
	}

{'fraction_non_alphanumeric': 0.12988997555012224, 'fraction_numerical': 0.0012224938875305623, 'mean_word_length': 2.8146853146853146, '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': '449383', 'n_tokens_mistral': 1254, 'n_tokens_neox': 1227, 'n_words': 327}