<commit_before>package jantar

import (
	"fmt"
	"io"
	"log"
	"os"
)

// Defines the various logging level
const (
	LogLevelDebug   = iota
	LogLevelInfo    = iota
	LogLevelWarning = iota
	LogLevelError   = iota
	LogLevelFatal   = iota
	LogLevelPanic   = iota
)

const (
	nocolor = 0
	red     = 31
	green   = 32
	yellow  = 33
	blue    = 34
)

// JLogger is a simple Log with some handy functions. Largely inspired by https://github.com/Sirupsen/logrus
type JLogger struct {
	log      *log.Logger
	minLevel uint
	ansiMode bool
}

// JLData is a type describing map that can be passed to Data<Level>f functions for debug output
type JLData map[string]interface{}

func levelToColor(level uint) int {
	switch level {
	case LogLevelInfo:
		return blue
	case LogLevelDebug:
		return green
	case LogLevelWarning:
		return yellow
	case LogLevelError:
		fallthrough
	case LogLevelFatal:
		fallthrough
	case LogLevelPanic:
		return red
	default:
		return nocolor
	}
}

func levelToString(level uint) string {
	switch level {
	case LogLevelInfo:
		return "INFO"
	case LogLevelDebug:
		return "DEBU"
	case LogLevelWarning:
		return "WARN"
	case LogLevelError:
		return "ERRO"
	case LogLevelFatal:
		return "FATA"
	case LogLevelPanic:
		return "PANI"
	default:
		return "Unknown"
	}
}

// NewJLogger creates a new JLogger instance
func NewJLogger(out io.Writer, prefix string, minLevel uint) *JLogger {
	ansiMode := false
	if isTerminal(os.Stderr.Fd()) {
		ansiMode = true
	}

	return &JLogger{log.New(out, prefix, 0), minLevel, ansiMode}
}

// SetMinLevel changes the loggers current minimal logging level
func (l *JLogger) SetMinLevel(minLevel uint) {
	if minLevel < LogLevelInfo || minLevel > LogLevelPanic {
		l.minLevel = LogLevelInfo
	} else {
		l.minLevel = minLevel
	}
}

// Infodf is equivalent to Infof but takes additional data to display
func (l *JLogger) Infodf(data JLData, format string, v ...interface{}) {
	l.printData(LogLevelInfo, data, format, v...)
}

// Debugdf is equivalent to Infodf but uses a different logging level
func (l *JLogger) Debugdf(data JLData, format string, v ...interface{}) {
	l.printData(LogLevelDebug, data, format, v...)
}

// Warningdf is equivalent to Infodf but uses a different logging level
func (l *JLogger) Warningdf(data JLData, format string, v ...interface{}) {
	l.printData(LogLevelWarning, data, format, v...)
}<commit_msg>fixed debug level in logger<commit_after>package jantar

import (
	"fmt"
	"io"
	"log"
	"os"
)

// Defines the various logging level
const (
	LogLevelDebug   = iota
	LogLevelInfo    = iota
	LogLevelWarning = iota
	LogLevelError   = iota
	LogLevelFatal   = iota
	LogLevelPanic   = iota
)

const (
	nocolor = 0
	red     = 31
	green   = 32
	yellow  = 33
	blue    = 34
)

// JLogger is a simple Log with some handy functions. Largely inspired by https://github.com/Sirupsen/logrus
type JLogger struct {
	log      *log.Logger
	minLevel uint
	ansiMode bool
}

// JLData is a type describing map that can be passed to Data<Level>f functions for debug output
type JLData map[string]interface{}

func levelToColor(level uint) int {
	switch level {
	case LogLevelDebug:
		return green
	case LogLevelInfo:
		return blue
	case LogLevelWarning:
		return yellow
	case LogLevelError:
		fallthrough
	case LogLevelFatal:
		fallthrough
	case LogLevelPanic:
		return red
	default:
		return nocolor
	}
}

func levelToString(level uint) string {
	switch level {
	case LogLevelDebug:
		return "DEBU"
	case LogLevelInfo:
		return "INFO"
	case LogLevelWarning:
		return "WARN"
	case LogLevelError:
		return "ERRO"
	case LogLevelFatal:
		return "FATA"
	case LogLevelPanic:
		return "PANI"
	default:
		return "Unknown"
	}
}

// NewJLogger creates a new JLogger instance
func NewJLogger(out io.Writer, prefix string, minLevel uint) *JLogger {
	ansiMode := false
	if isTerminal(os.Stderr.Fd()) {
		ansiMode = true
	}

	return &JLogger{log.New(out, prefix, 0), minLevel, ansiMode}
}

// SetMinLevel changes the loggers current minimal logging level
func (l *JLogger) SetMinLevel(minLevel uint) {
	if minLevel < LogLevelDebug || minLevel > LogLevelPanic {
		l.minLevel = LogLevelInfo
	} else {
		l.minLevel = minLevel
	}
}

// Infodf is equivalent to Infof but takes additional data to display
func (l *JLogger) Infodf(data JLData, format string, v ...interface{}) {
	l.printData(LogLevelInfo, data, format, v...)
}

// Debugdf is equivalent to Infodf but uses a different logging level
func (l *JLogger) Debugdf(data JLData, format string, v ...interface{}) {
	l.printData(LogLevelDebug, data, format, v...)
}

// Warningdf is equivalent to Infodf but uses a different logging level
func (l *JLogger) Warningdf(data JLData, format string, v ...interface{}) {
	l.printData(LogLevelWarning, data, format, v...)
}
{'fraction_non_alphanumeric': 0.09188619599578504, 'fraction_numerical': 0.004214963119072708, 'mean_word_length': 3.837920489296636, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '3037462', 'n_tokens_mistral': 1679, 'n_tokens_neox': 1607, 'n_words': 528}