<commit_before>// Debug functions.
package debug

import (
	"fmt"
	"log"
	"os"
	"runtime"
)

// Set Logger to nil to suppress debug output
var Logger *log.Logger = log.New(os.Stdout, "", 0)

func CallStackInfo(skip int) (info string) {
	if pc, file, line, ok := runtime.Caller(skip); ok {
		funcName := runtime.FuncForPC(pc).Name()
		info += fmt.Sprintf("%s()\n%s:%d", funcName, file, line)
	}
	if _, file, line, ok := runtime.Caller(skip + 1); ok {
		info += fmt.Sprintf("\n%s:%d", file, line)
	}
	return
}

func FormatSkip(skip int, value interface{}) string {
	callstack := CallStackInfo(skip + 1)
	return fmt.Sprintf("\n     Type: %T\n    Value: %v\nGo Syntax: %#v\nCallstack: %s", value, value, value, callstack)
}

func Format(value interface{}) string {
	return FormatSkip(2, value)
}

func Dump(values ...interface{}) {
	if Logger == nil {
		return<commit_msg>added debug.PrintCallStack()<commit_after>// Debug functions.
package debug

import (
	"fmt"
	"log"
	"os"
	"runtime"
	"runtime/debug"
)

// Set Logger to nil to suppress debug output
var Logger *log.Logger = log.New(os.Stdout, "", 0)

func CallStackInfo(skip int) (info string) {
	if pc, file, line, ok := runtime.Caller(skip); ok {
		funcName := runtime.FuncForPC(pc).Name()
		info += fmt.Sprintf("%s()\n%s:%d", funcName, file, line)
	}
	if _, file, line, ok := runtime.Caller(skip + 1); ok {
		info += fmt.Sprintf("\n%s:%d", file, line)
	}
	return
}

func PrintCallStack() {
	fmt.Println(string(debug.Stack()))
}

func FormatSkip(skip int, value interface{}) string {
	callstack := CallStackInfo(skip + 1)
	return fmt.Sprintf("\n     Type: %T\n    Value: %v\nGo Syntax: %#v\nCallstack: %s", value, value, value, callstack)
}

func Format(value interface{}) string {
	return FormatSkip(2, value)
}

func Dump(values ...interface{}) {
	if Logger == nil {
		return
{'fraction_non_alphanumeric': 0.1736755871108684, 'fraction_numerical': 0.004369197160021846, 'mean_word_length': 4.046831955922865, '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': '7410564', 'n_tokens_mistral': 679, 'n_tokens_neox': 664, 'n_words': 184}