<commit_before>package main

import (
	"bufio"
	"io"
	"log"
	"os"
	"os/exec"
	"time"
)

func init() {
	f, _ := os.OpenFile("/var/log/sendmail-logger.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
	log.SetOutput(f)
}

func main() {
	body := ""
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		body += scanner.Text() + "\n"
	}
	if err := scanner.Err(); err != nil {
		log.Fatal(err)
	}
	defer SendMail(body)

	conf, err := LoadConfig()
	if err != nil {
		log.Print(err)
		return
	}
	file, err := os.OpenFile(conf.LogFile, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0664)
	if err != nil {
		log.Print(err)
		return
	}
	defer file.Close()

	header := "Sendmail Date: " + time.Now().String()
	file.Write(([]byte)(header + "\n" + body))
}

func SendMail(body string) {
	sendmail := exec.Command("sendmail", "-t")
	stdin, _ := sendmail.StdinPipe()

	err := sendmail.Start()
	if err != nil {
		log.Fatal(err)
	}
	io.WriteString(stdin, body+".\n")

	err = sendmail.Wait()
	if err != nil {
		log.Fatal(err)
	}
}<commit_msg>add -i option to sendmail command<commit_after>package main

import (
	"bufio"
	"io"
	"log"
	"os"
	"os/exec"
	"time"
)

func init() {
	f, _ := os.OpenFile("/var/log/sendmail-logger.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
	log.SetOutput(f)
}

func main() {
	body := ""
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		body += scanner.Text() + "\n"
	}
	if err := scanner.Err(); err != nil {
		log.Fatal(err)
	}
	defer SendMail(body)

	conf, err := LoadConfig()
	if err != nil {
		log.Print(err)
		return
	}
	file, err := os.OpenFile(conf.LogFile, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0664)
	if err != nil {
		log.Print(err)
		return
	}
	defer file.Close()

	header := "Sendmail Date: " + time.Now().String()
	file.Write(([]byte)(header + "\n" + body))
}

func SendMail(body string) {
	sendmail := exec.Command("sendmail", "-t", "-i")
	stdin, _ := sendmail.StdinPipe()

	io.WriteString(stdin, body)
	stdin.Close()

	err := sendmail.Run()
	if err != nil {
		log.Fatal(err)
	}
}
{'fraction_non_alphanumeric': 0.19751861042183622, 'fraction_numerical': 0.00794044665012407, 'mean_word_length': 3.5714285714285716, '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': '5534728', 'n_tokens_mistral': 911, 'n_tokens_neox': 863, 'n_words': 167}