<commit_before>package main

import (
	"encoding/json"
	"errors"
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
)

func HealthHandler(w http.ResponseWriter, r *http.Request) {
	fmt.Fprintln(w, "OK")
}

type Event struct {
	Type string `json:"eventType"`
}

type ForwardHandler struct {
	kv      PutDeleter
	Verbose bool
	Debug   bool
}

func (fh *ForwardHandler) LogVerbose(s string) {
	if fh.Verbose {
		fmt.Printf("[INFO] %s\n", s)
	}
}

func (fh *ForwardHandler) LogDebug(s string) {
	if fh.Debug {

		fmt.Printf("[DEBUG] %s\n", s)
	}
}

func (fh *ForwardHandler) Handle(w http.ResponseWriter, r *http.Request) {
	body, err := ioutil.ReadAll(r.Body)
	if err != nil || len(body) == 0 {
		w.WriteHeader(500)
		fmt.Fprintln(w, "could not read request body")
		return
	}

	event := Event{}
	err = json.Unmarshal(body, &event)
	if err != nil {
		w.WriteHeader(500)
		fmt.Fprintln(w, err.Error())
		return
	}

	switch event.Type {
	case "api_post_event", "deployment_info":
		fh.LogVerbose(fmt.Sprintf("handling \"%s\"", event.Type))
		fh.HandleAppEvent(w, body)
	case "status_update_event":
		fh.LogVerbose("handling \"status_update_event\"")
		fh.HandleStatusEvent(w, body)
	default:
		fh.LogVerbose(fmt.Sprintf("not handling \"%s\"", event.Type))
		w.WriteHeader(200)
		fmt.Fprintf(w, "cannot handle %s\n", event.Type)<commit_msg>web: log with timestamp instead of just printing<commit_after>package main

import (
	"encoding/json"
	"errors"
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
)

func HealthHandler(w http.ResponseWriter, r *http.Request) {
	fmt.Fprintln(w, "OK")
}

type Event struct {
	Type string `json:"eventType"`
}

type ForwardHandler struct {
	kv      PutDeleter
	Verbose bool
	Debug   bool
}

func (fh *ForwardHandler) LogVerbose(s string) {
	if fh.Verbose {
		log.Printf("[INFO] %s\n", s)
	}
}

func (fh *ForwardHandler) LogDebug(s string) {
	if fh.Debug {
		log.Printf("[DEBUG] %s\n", s)
	}
}

func (fh *ForwardHandler) Handle(w http.ResponseWriter, r *http.Request) {
	body, err := ioutil.ReadAll(r.Body)
	if err != nil || len(body) == 0 {
		w.WriteHeader(500)
		fmt.Fprintln(w, "could not read request body")
		return
	}

	event := Event{}
	err = json.Unmarshal(body, &event)
	if err != nil {
		w.WriteHeader(500)
		fmt.Fprintln(w, err.Error())
		return
	}

	switch event.Type {
	case "api_post_event", "deployment_info":
		fh.LogVerbose(fmt.Sprintf("handling \"%s\"", event.Type))
		fh.HandleAppEvent(w, body)
	case "status_update_event":
		fh.LogVerbose("handling \"status_update_event\"")
		fh.HandleStatusEvent(w, body)
	default:
		fh.LogVerbose(fmt.Sprintf("not handling \"%s\"", event.Type))
		w.WriteHeader(200)
		fmt.Fprintf(w, "cannot handle %s\n", event.Type)
{'fraction_non_alphanumeric': 0.160941000746826, 'fraction_numerical': 0.0074682598954443615, 'mean_word_length': 4.161849710982659, 'pattern_counts': {'":': 4, '<': 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': '1602584', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1057, 'n_words': 234}