<commit_before>package log

import (
	"bytes"
	"fmt"
	"io"
	"os"
	"reflect"
	"strconv"
	"strings"
	"time"
)

type ioLogger struct {
	c   chan Event
	out io.Writer
	buf []byte
}

var (
	sub *Subscription
)

func init() {
	l := &ioLogger{c: make(chan Event, 100), out: os.Stderr}
	resetEventSubscriber(func(evt Event) {
		l.c <- evt
	})
	go l.listenEvent()
}

func resetEventSubscriber(f func(evt Event)) {
	if sub != nil {
		Unsubscribe(sub)
		sub = nil
	}
	sub = Subscribe(f)
}

func (l *ioLogger) listenEvent() {
	for true {
		e := <-l.c
		l.writeEvent(e)<commit_msg>feat: add exported function to disable proto.actor's standard error logs if additional subscribers are registered<commit_after>package log

import (
	"bytes"
	"fmt"
	"io"
	"os"
	"reflect"
	"strconv"
	"strings"
	"time"
)

type ioLogger struct {
	c   chan Event
	out io.Writer
	buf []byte
}

var (
	noStdErrLogs bool
	sub          *Subscription
)

// Disables Proto.Actor standard error logs if there is one
// or more additional log subscribers registered
func SetNoStdErrLogs() {

	if len(es.subscriptions) >= 2 {
		noStdErrLogs = true
	}
}

func init() {
	l := &ioLogger{c: make(chan Event, 100), out: os.Stderr}
	resetEventSubscriber(func(evt Event) {
		l.c <- evt
	})
	go l.listenEvent()
}

func resetEventSubscriber(f func(evt Event)) {
	if sub != nil {
		Unsubscribe(sub)
		sub = nil
	}
	sub = Subscribe(f)
}

func (l *ioLogger) listenEvent() {
	for true {
		if noStdErrLogs {
			break
		}

		e := <-l.c
		l.writeEvent(e)
{'fraction_non_alphanumeric': 0.13253012048192772, 'fraction_numerical': 0.004685408299866131, 'mean_word_length': 3.43620178041543, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 4, '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': '1032658', 'n_tokens_mistral': 620, 'n_tokens_neox': 592, 'n_words': 160}