<commit_before>package middleware

import (
	"github.com/andviro/noodle"
	"golang.org/x/net/context"
	"log"
	"net/http"
	"sync"
	"time"
)

var writers sync.Pool

// logWriter mimics http.ResponseWriter functionality while storing
// HTTP status code for later logging
type logWriter struct {
	code          int
	headerWritten bool
	http.ResponseWriter
}

func (l *logWriter) WriteHeader(code int) {
	l.ResponseWriter.WriteHeader(code)
	if !l.headerWritten {
		l.code = code
		l.headerWritten = true
	}
}

func (l *logWriter) Write(buf []byte) (int, error) {
	l.headerWritten = true
	return l.ResponseWriter.Write(buf)
}

func (l *logWriter) Code() int {
	if !l.headerWritten {
		return 200
	}
	return l.code
}
<commit_msg>hot fix for logger<commit_after>package middleware

import (
	"github.com/andviro/noodle"
	"golang.org/x/net/context"
	"log"
	"net/http"
	"sync"
	"time"
)

var writers sync.Pool

// logWriter mimics http.ResponseWriter functionality while storing
// HTTP status code for later logging
type logWriter struct {
	code          int
	headerWritten bool
	http.ResponseWriter
}

func (l *logWriter) WriteHeader(code int) {
	l.ResponseWriter.WriteHeader(code)
	if !l.headerWritten {
		l.code = code
		l.headerWritten = true
	}
}

func (l *logWriter) Write(buf []byte) (int, error) {
	l.headerWritten = true
	return l.ResponseWriter.Write(buf)
}

func (l *logWriter) Code() int {
	if l.code == 0 {
		return 200
	}
	return l.code
}

{'fraction_non_alphanumeric': 0.11565096952908588, 'fraction_numerical': 0.004847645429362881, 'mean_word_length': 3.7847682119205297, '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': '4399415', 'n_tokens_mistral': 548, 'n_tokens_neox': 517, 'n_words': 136}