<commit_before>package log

import (
	"fmt"
	"runtime"
	"strconv"
	"strings"
	"time"
)

type Formatter interface {
	Format(Level, string) []byte
}

// Standard Formatter
type StdFormatter struct {
	Prefix  string // prefix to write at beginning of each line
	Flag    int    // format flags - based flags from std log package
	Colored bool   // use colored level names
}

func (this StdFormatter) Format(level Level, msg string) []byte {
	var slevel string
	var ok bool
	var out []string

	// adding time info
	if this.Flag&(Ldate|Ltime|Lmicroseconds) != 0 {
		now := time.Now()
		if this.Flag&Ldate != 0 {
			out = append(out, fmt.Sprintf("%v-%02d-%02d", now.Year(), now.Month(), now.Day()))
		}
		if this.Flag&(Lmicroseconds) != 0 {
			out = append(out, fmt.Sprintf("%02d:%02d:%02d.%06d", now.Hour(), now.Minute(), now.Second(), now.Nanosecond()/1000000))
		} else if this.Flag&(Ltime) != 0 {
			out = append(out, fmt.Sprintf("%02d:%02d:%02d", now.Hour(), now.Minute(), now.Second()))
		}
	}

	// adding level info
	if this.Colored {
		slevel, ok = levelCStrings[level]
	} else {
		slevel, ok = levelStrings[level]
	}
	if !ok {
		slevel = strconv.Itoa(int(level))
	}
	out = append(out, slevel)

	out = append(out, this.Prefix)

	// adding caller info. It's quiet exepnsive
	if this.Flag&(Lshortfile|Llongfile) != 0 {
		if _, file, line, ok := runtime.Caller(2); ok { // 2: calldepth
			if this.Flag&Lshortfile != 0 {
				file = file[strings.LastIndex(file, "/")+1:]
			}
			out = append(out, fmt.Sprintf("%s:%d", file, line))
		} else {
			out = append(out, "???")
		}
	}

	out = append(out, msg)
	return []byte(strings.Join(out, " "))
}<commit_msg>Changed prefix position in log message<commit_after>package log

import (
	"fmt"
	"runtime"
	"strconv"
	"strings"
	"time"
)

type Formatter interface {
	Format(Level, string) []byte
}

// Standard Formatter
type StdFormatter struct {
	Prefix  string // prefix to write at beginning of each line
	Flag    int    // format flags - based flags from std log package
	Colored bool   // use colored level names
}

func (this StdFormatter) Format(level Level, msg string) []byte {
	var slevel string
	var ok bool
	var out []string

	// adding time info
	if this.Flag&(Ldate|Ltime|Lmicroseconds) != 0 {
		now := time.Now()
		if this.Flag&Ldate != 0 {
			out = append(out, fmt.Sprintf("%v-%02d-%02d", now.Year(), now.Month(), now.Day()))
		}
		if this.Flag&(Lmicroseconds) != 0 {
			out = append(out, fmt.Sprintf("%02d:%02d:%02d.%06d", now.Hour(), now.Minute(), now.Second(), now.Nanosecond()/1000000))
		} else if this.Flag&(Ltime) != 0 {
			out = append(out, fmt.Sprintf("%02d:%02d:%02d", now.Hour(), now.Minute(), now.Second()))
		}
	}

	// adding level info
	if this.Colored {
		slevel, ok = levelCStrings[level]
	} else {
		slevel, ok = levelStrings[level]
	}
	if !ok {
		slevel = strconv.Itoa(int(level))
	}
	out = append(out, slevel)

	// adding caller info. It's quiet exepnsive
	if this.Flag&(Lshortfile|Llongfile) != 0 {
		if _, file, line, ok := runtime.Caller(2); ok { // 2: calldepth
			if this.Flag&Lshortfile != 0 {
				file = file[strings.LastIndex(file, "/")+1:]
			}
			out = append(out, fmt.Sprintf("%s:%d", file, line))
		} else {
			out = append(out, "???")
		}
	}

	out = append(out, this.Prefix)
	out = append(out, msg)
	return []byte(strings.Join(out, " "))
}
{'fraction_non_alphanumeric': 0.17148014440433212, 'fraction_numerical': 0.02045728038507822, 'mean_word_length': 3.5361527967257844, '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': '173698', 'n_tokens_mistral': 1355, 'n_tokens_neox': 1230, 'n_words': 319}