<commit_before>package bunyan

import (
	"fmt"
	"log"
)

type Logger struct {
	*log.Logger
	name    string
	streams []StreamInterface
}

// Creates a new logger, given one or more streams
func NewLogger(name string, streams []StreamInterface) *Logger {
	return &Logger{
		name:    name,
		streams: streams,
	}
}

func (l *Logger) AddStream(s StreamInterface) {
	l.streams = append(l.streams, s)
}

func (l *Logger) Log(e *LogEntry) {
	e.setLogger(l)

	for _, stream := range l.streams {
		go stream.Publish(e)
	}
}

func (l *Logger) Logln(level LogLevel, message string) *LogEntry {
	e := NewLogEntry(level, message)

	l.Log(e)

	return e
}

func (l *Logger) LogF(level LogLevel, format string, values ...interface{}) *LogEntry {
	e := NewLogEntry(level, fmt.Sprintf(format, values...))<commit_msg>- Added sync reporting and global minimum reporting level<commit_after>package bunyan

import (
	"fmt"
	"log"
)

type Logger struct {
	*log.Logger
	name        string
	streams     []StreamInterface
	sync        bool
	minLogLevel LogLevel
}

// Creates a new logger, given one or more streams
func NewLogger(name string, streams []StreamInterface) *Logger {
	return &Logger{
		name:     name,
		streams:  streams,
		sync:     false,
		minLevel: 0,
	}
}

func (l *Logger) SetSynchronous(sync bool) {
	l.sync = sync
}

func (l *Logger) SetGlobalMinLogLevel(minLogLevel LogLevel) {
	l.minLevel = minLogLevel
}

func (l *Logger) AddStream(s StreamInterface) {
	l.streams = append(l.streams, s)
}

func (l *Logger) Log(e *LogEntry) {
	e.setLogger(l)

	if e.Level < l.minLogLevel {
		return
	}

	if l.sync {
		for _, stream := range l.streams {
			stream.Publish(e)
		}
	} else {
		for _, stream := range l.streams {
			go stream.Publish(e)
		}

	}
}

func (l *Logger) Logln(level LogLevel, message string) *LogEntry {
	e := NewLogEntry(level, message)

	l.Log(e)

	return e
}

func (l *Logger) LogF(level LogLevel, format string, values ...interface{}) *LogEntry {
	e := NewLogEntry(level, fmt.Sprintf(format, values...))
{'fraction_non_alphanumeric': 0.12916045702930948, 'fraction_numerical': 0.0004967709885742673, 'mean_word_length': 3.683720930232558, 'pattern_counts': {'":': 0, '<': 4, '<?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': '4251927', 'n_tokens_mistral': 754, 'n_tokens_neox': 725, 'n_words': 205}