<commit_before>package common

import (
	"fmt"
	slog "log"
	"os"
	"path/filepath"
	"strings"
	"time"
)

var logfile *os.File

func init() {
	var err error
	logPath := filepath.Join(GetCurrentDir(), LOG_PATH)
	logfile, err = os.OpenFile(filepath.Join(logPath, "access.log"), os.O_APPEND|os.O_WRONLY|os.O_CREATE, os.ModePerm)
	if err != nil {
		slog.Printf("ERROR log file: %+v", err)
		return
	}
	logfile.WriteString("")
}

type log struct {
	enable bool
	debug  bool
	info   bool
	warn   bool
	error  bool
}

func (l *log) Info(format string, v ...interface{}) {
	if l.info && l.enable {
		message := fmt.Sprintf("%s SYST INFO ", l.now())
		message = fmt.Sprintf(message+format+"\n", v...)

		logfile.WriteString(message)
		fmt.Printf(strings.Replace(message, "%", "%%", -1))
	}
}

func (l *log) Warning(format string, v ...interface{}) {
	if l.warn && l.enable {
		message := fmt.Sprintf("%s SYST WARN ", l.now())
		message = fmt.Sprintf(message+format+"\n", v...)

		logfile.WriteString(message)
		fmt.Printf(strings.Replace(message, "%", "%%", -1))
	}
}

func (l *log) Error(format string, v ...interface{}) {
	if l.error && l.enable {
		message := fmt.Sprintf("%s SYST ERROR ", l.now())
		message = fmt.Sprintf(message+format+"\n", v...)

		logfile.WriteString(message)
		fmt.Printf(strings.Replace(message, "%", "%%", -1))
	}
}

func (l *log) Debug(format string, v ...interface{}) {
	if l.debug && l.enable {
		message := fmt.Sprintf("%s SYST DEBUG ", l.now())
		message = fmt.Sprintf(message+format+"\n", v...)

		logfile.WriteString(message)
		fmt.Printf(strings.Replace(message, "%", "%%", -1))
	}
}

func (l *log) Stdout(format string, v ...interface{}) {
	message := fmt.Sprintf("%s ", l.now())
	message = fmt.Sprintf(message+format+"\n", v...)
	fmt.Printf(strings.Replace(message, "%", "%%", -1))
}
<commit_msg>fix (log): log to file when using Log.Stdout<commit_after>package common

import (
	"fmt"
	slog "log"
	"os"
	"path/filepath"
	"strings"
	"time"
)

var logfile *os.File

func init() {
	var err error
	logPath := filepath.Join(GetCurrentDir(), LOG_PATH)
	logfile, err = os.OpenFile(filepath.Join(logPath, "access.log"), os.O_APPEND|os.O_WRONLY|os.O_CREATE, os.ModePerm)
	if err != nil {
		slog.Printf("ERROR log file: %+v", err)
		return
	}
	logfile.WriteString("")
}

type log struct {
	enable bool
	debug  bool
	info   bool
	warn   bool
	error  bool
}

func (l *log) Info(format string, v ...interface{}) {
	if l.info && l.enable {
		message := fmt.Sprintf("%s SYST INFO ", l.now())
		message = fmt.Sprintf(message+format+"\n", v...)

		logfile.WriteString(message)
		fmt.Printf(strings.Replace(message, "%", "%%", -1))
	}
}

func (l *log) Warning(format string, v ...interface{}) {
	if l.warn && l.enable {
		message := fmt.Sprintf("%s SYST WARN ", l.now())
		message = fmt.Sprintf(message+format+"\n", v...)

		logfile.WriteString(message)
		fmt.Printf(strings.Replace(message, "%", "%%", -1))
	}
}

func (l *log) Error(format string, v ...interface{}) {
	if l.error && l.enable {
		message := fmt.Sprintf("%s SYST ERROR ", l.now())
		message = fmt.Sprintf(message+format+"\n", v...)

		logfile.WriteString(message)
		fmt.Printf(strings.Replace(message, "%", "%%", -1))
	}
}

func (l *log) Debug(format string, v ...interface{}) {
	if l.debug && l.enable {
		message := fmt.Sprintf("%s SYST DEBUG ", l.now())
		message = fmt.Sprintf(message+format+"\n", v...)

		logfile.WriteString(message)
		fmt.Printf(strings.Replace(message, "%", "%%", -1))
	}
}

func (l *log) Stdout(format string, v ...interface{}) {
	message := fmt.Sprintf("%s ", l.now())
	message = fmt.Sprintf(message+format+"\n", v...)

	logfile.WriteString(message)
	fmt.Printf(strings.Replace(message, "%", "%%", -1))
}

{'fraction_non_alphanumeric': 0.20846817691477887, 'fraction_numerical': 0.002696871628910464, 'mean_word_length': 3.810635538261997, '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': '3908178', 'n_tokens_mistral': 1428, 'n_tokens_neox': 1390, 'n_words': 306}