<commit_before>package main

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

var (
	client    *http.Client
	count     int64
	hookCount int64
)

func init() {
	client = &http.Client{}
	count = 0
	hookCount = 0
}

// HandleStatus is a simple health-check endpoint
// that will tell the user the total number of
// successful analyses and the number of successful
// hooked requests (a subset of the former) made
func HandleStatus(r http.ResponseWriter, req *http.Request) {
	r.Header().Add("Content-Type", "application/json")
	r.WriteHeader(http.StatusOK)

	// send the total successful count
	// and total error count
	r.Write([]byte(fmt.Sprintf(`{
		"status": "Up",
		"totalSuccessfulAnalyses": %v,
		"hookedRequests": %v
	}`, count, hookCount)))
}

// HandleSentiment takes in a POST with JSON
// containing a 'text' param. The handler runs<commit_msg>Added logging to health check endpoint<commit_after>package main

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

var (
	client    *http.Client
	count     int64
	hookCount int64
)

func init() {
	client = &http.Client{}
	count = 0
	hookCount = 0
}

// HandleStatus is a simple health-check endpoint
// that will tell the user the total number of
// successful analyses and the number of successful
// hooked requests (a subset of the former) made
func HandleStatus(r http.ResponseWriter, req *http.Request) {
	r.Header().Add("Content-Type", "application/json")
	r.WriteHeader(http.StatusOK)

	// send the total successful count
	// and total error count
	r.Write([]byte(fmt.Sprintf(`{
		"status": "Up",
		"totalSuccessfulAnalyses": %v,
		"hookedRequests": %v
	}`, count, hookCount)))

	log.Printf("GET / [totalSuccessfulAnalyses = %v]\n", count)
}

// HandleSentiment takes in a POST with JSON
// containing a 'text' param. The handler runs
{'fraction_non_alphanumeric': 0.12927756653992395, 'fraction_numerical': 0.006518196632265073, 'mean_word_length': 3.8093994778067883, 'pattern_counts': {'":': 6, '<': 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': '2578776', 'n_tokens_mistral': 632, 'n_tokens_neox': 608, 'n_words': 196}