<commit_before>package base

import (
	"errors"
	"fmt"
	"log"
	"os"

	"github.com/fatih/color"
)

var logBuffer chan string

func init() {
	logBuffer = make(chan string, 100000)

	go logger()
}

func Log(format string, values ...interface{}) {

	logBuffer <- fmt.Sprintf(format, values...)
}

func logger() {

	if len(os.Getenv("DEBUG_LOGS")) == 0 {

		f, err := os.OpenFile("/log.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
		if err != nil {
			msg := fmt.Sprintf("Couldn't open log file: %s", err)
			log.Printf(color.HiRedString(msg))
			panic(errors.New(msg))
		}
		defer f.Close()

		log.SetOutput(f)
	}

	for {
		log.Printf(<-logBuffer)
	}
}<commit_msg>changing logging directory<commit_after>package base

import (
	"errors"
	"fmt"
	"log"
	"os"

	"github.com/fatih/color"
)

var logBuffer chan string

func init() {
	logBuffer = make(chan string, 100000)

	go logger()
}

func Log(format string, values ...interface{}) {

	logBuffer <- fmt.Sprintf(format, values...)
}

func logger() {

	if len(os.Getenv("DEBUG_LOGS")) == 0 {

		f, err := os.OpenFile("/var/log/av-api.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
		if err != nil {
			msg := fmt.Sprintf("Couldn't open log file: %s", err)
			log.Printf(color.HiRedString(msg))
			panic(errors.New(msg))
		}
		defer f.Close()

		log.SetOutput(f)
	}

	for {
		log.Printf(<-logBuffer)
	}
}
{'fraction_non_alphanumeric': 0.17729970326409494, 'fraction_numerical': 0.016320474777448073, 'mean_word_length': 3.5574324324324325, 'pattern_counts': {'":': 0, '<': 7, '<?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': '3973754', 'n_tokens_mistral': 601, 'n_tokens_neox': 535, 'n_words': 112}