<commit_before>package log

import (
	"fmt"
	"os"
)

const (
	// LvlOutline shows client version & arguments passed in, HTTP URLs & status codes, subprocess calls.
	LvlOutline = 1 + iota
	// LvlArgs shows args going in to library functions
	LvlArgs
	// LvlFlags is used to show/hide the way flags and command line arguments are being messed with in main
	LvlFlags
	// LvlHTTPData is used to show/hide raw HTTP request and response bodies.
	LvlHTTPData
	// LvlMisc is used for any other minutiae
	LvlMisc
)

// DebugLevel determines whether or not debugging output should be output to stderr.
var DebugLevel int

// LogFile is the file which bytemark-client is to log to. This can be nil, in which case it won't. Usually ~/.bytemark/debug.log
var LogFile *os.File

// Error outputs stuff to os.Stderr and LogFile, one thing per line.
func Error(stuff ...interface{}) {
	if len(stuff) == 0 {
		Error("")
	}
	for _, v := range stuff {
		_, _ = fmt.Fprintln(os.Stderr, v)
		if LogFile != nil {
			_, _ = fmt.Fprintln(LogFile, v)
		}
	}

}

// Errorf formats the string and outputs it to Stderr and Logfile.
func Errorf(format string, args ...interface{}) {
	_, _ = fmt.Fprintf(os.Stderr, format, args...)
	if LogFile != nil {
		_, _ = fmt.Fprintf(LogFile, format, args...)
	}
}

// Log outputs stuff to os.Stderr and LogFile, one thing per line.
func Log(stuff ...interface{}) {
	if len(stuff) == 0 {
		Log("")
	}
	for _, v := range stuff {
		_, _ = fmt.Fprintln(os.Stderr, v)
		if LogFile != nil {
			_, _ = fmt.Fprintln(LogFile, v)
		}
	}
}

// Logf formats the string and outputs it to Stderr and Logfile.
func Logf(format string, args ...interface{}) {
	_, _ = fmt.Fprintf(os.Stderr, format, args...)
	if LogFile != nil {
		_, _ = fmt.Fprintf(LogFile, format, args...)
	}
}

// Output outputs stuff to os.Stdout and LogFile, one thing per line.
func Output(stuff ...interface{}) {

	if len(stuff) == 0 {
		Output("")
	}
	for _, v := range stuff {
		fmt.Println(v)
		if LogFile != nil {
			_, _ = fmt.Fprintln(LogFile, v)
		}
	}
}

// Outputf formats the string and outputs it to Stdout and Logfile.
func Outputf(format string, args ...interface{}) {
	fmt.Printf(format, args...)
	if LogFile != nil {
		_, _ = fmt.Fprintf(LogFile, format, args...)
	}
}

// Debug outputs stuff to LogFile, and to Stderr if DebugLevel >= level. One thing per line.
func Debug(level int, stuff ...interface{}) {
	for _, v := range stuff {
		if level <= DebugLevel {
			_, _ = fmt.Fprintln(os.Stderr, v)
		}
		if LogFile != nil {
			_, _ = fmt.Fprintln(LogFile, v)
		}
	}
}

// Debugf formats the string and outputs it to LogFile, and to Stderr if DebugLevel >= level.
func Debugf(level int, format string, args ...interface{}) {
	if level <= DebugLevel {
		_, _ = fmt.Fprintf(os.Stderr, format, args...)
	}
	if LogFile != nil {
		_, _ = fmt.Fprintf(LogFile, format, args...)
	}
}<commit_msg>Revert "Ignore errors writing to stdout/stderr/log file"<commit_after>package log

import (
	"fmt"
	"os"
)

const (
	// LvlOutline shows client version & arguments passed in, HTTP URLs & status codes, subprocess calls.
	LvlOutline = 1 + iota
	// LvlArgs shows args going in to library functions
	LvlArgs
	// LvlFlags is used to show/hide the way flags and command line arguments are being messed with in main
	LvlFlags
	// LvlHTTPData is used to show/hide raw HTTP request and response bodies.
	LvlHTTPData
	// LvlMisc is used for any other minutiae
	LvlMisc
)

// DebugLevel determines whether or not debugging output should be output to stderr.
var DebugLevel int

// LogFile is the file which bytemark-client is to log to. This can be nil, in which case it won't. Usually ~/.bytemark/debug.log
var LogFile *os.File

// Error outputs stuff to os.Stderr and LogFile, one thing per line.
func Error(stuff ...interface{}) {
	if len(stuff) == 0 {
		Error("")
	}
	for _, v := range stuff {
		fmt.Fprintln(os.Stderr, v)
		if LogFile != nil {
			fmt.Fprintln(LogFile, v)
		}
	}

}

// Errorf formats the string and outputs it to Stderr and Logfile.
func Errorf(format string, args ...interface{}) {
	fmt.Fprintf(os.Stderr, format, args...)
	if LogFile != nil {
		fmt.Fprintf(LogFile, format, args...)
	}
}

// Log outputs stuff to os.Stderr and LogFile, one thing per line.
func Log(stuff ...interface{}) {
	if len(stuff) == 0 {
		Log("")
	}
	for _, v := range stuff {
		fmt.Fprintln(os.Stderr, v)
		if LogFile != nil {
			fmt.Fprintln(LogFile, v)
		}
	}
}

// Logf formats the string and outputs it to Stderr and Logfile.
func Logf(format string, args ...interface{}) {
	fmt.Fprintf(os.Stderr, format, args...)
	if LogFile != nil {
		fmt.Fprintf(LogFile, format, args...)
	}
}

// Output outputs stuff to os.Stdout and LogFile, one thing per line.
func Output(stuff ...interface{}) {

	if len(stuff) == 0 {
		Output("")
	}
	for _, v := range stuff {
		fmt.Println(v)
		if LogFile != nil {
			fmt.Fprintln(LogFile, v)
		}
	}
}

// Outputf formats the string and outputs it to Stdout and Logfile.
func Outputf(format string, args ...interface{}) {
	fmt.Printf(format, args...)
	if LogFile != nil {
		fmt.Fprintf(LogFile, format, args...)
	}
}

// Debug outputs stuff to LogFile, and to Stderr if DebugLevel >= level. One thing per line.
func Debug(level int, stuff ...interface{}) {
	for _, v := range stuff {
		if level <= DebugLevel {
			fmt.Fprintln(os.Stderr, v)
		}
		if LogFile != nil {
			fmt.Fprintln(LogFile, v)
		}
	}
}

// Debugf formats the string and outputs it to LogFile, and to Stderr if DebugLevel >= level.
func Debugf(level int, format string, args ...interface{}) {
	if level <= DebugLevel {
		fmt.Fprintf(os.Stderr, format, args...)
	}
	if LogFile != nil {
		fmt.Fprintf(LogFile, format, args...)
	}
}
{'fraction_non_alphanumeric': 0.12976965007912783, 'fraction_numerical': 0.001406717074028486, 'mean_word_length': 3.1068592057761735, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '2078633', 'n_tokens_mistral': 2030, 'n_tokens_neox': 1930, 'n_words': 680}