<commit_before>package main

import (
	"flag"
	"fmt"
	"net/http"
	"os"
	"strconv"
	"strings"
	"time"

	"github.com/gorilla/mux"
	"github.com/newrelic/go-agent"
	"github.com/op/go-logging"
)

var logger = logging.MustGetLogger("hashi-ui")
var defaultConfig = DefaultConfig()

func startLogging(logLevel string) {
	logBackend := logging.NewLogBackend(os.Stderr, "", 0)

	format := logging.MustStringFormatter(
		`%{color}%{time:15:04:05.000} %{shortfile} ▶ %{level:.5s} %{color:reset} %{message}`,
	)
	logBackendFormatted := logging.NewBackendFormatter(logBackend, format)

	logBackendFormattedAndLeveled := logging.AddModuleLevel(logBackendFormatted)

	realLogLevel, err := logging.LogLevel(strings.ToUpper(logLevel))
	if err != nil {
		fmt.Printf("%s (%s)", err, logLevel)
		os.Exit(1)
	}

	logBackendFormattedAndLeveled.SetLevel(realLogLevel, "")

	logging.SetBackend(logBackendFormattedAndLeveled)
}

// Parse the env and cli flags and store the outcome in a Config struct
func (c *Config) Parse() {
	flag.Parse()

	ParseAppEnvConfig(c)
	ParseAppFlagConfig(c)

	ParseNomadEnvConfig(c)
	ParseNomadFlagConfig(c)

	ParseConsulEnvConfig(c)
	ParseConsulFlagConfig(c)

	ParseNewRelicConfig(c)
}

func main() {
	cfg := DefaultConfig()
	cfg.Parse()

	config := newrelic.NewConfig(cfg.NewRelicAppName, cfg.NewRelicLicense)
	config.Logger = newrelic.NewLogger(os.Stdout)

	if cfg.NewRelicAppName == "" || cfg.NewRelicLicense == "" {
		config.Enabled = false
	}

	_, err := newrelic.NewApplication(config)
	if err != nil {
		logger.Error(err)
		os.Exit(1)
	}

	startLogging(cfg.LogLevel)

	logger.Infof("-----------------------------------------------------------------------------")
	logger.Infof("|                             NOMAD UI                                      |")
	logger.Infof("-----------------------------------------------------------------------------")
	logger.Infof("| listen-address  	: http://%-43s |", cfg.ListenAddress)
	logger.Infof("| proxy-address   	: %-50s |", cfg.ProxyAddress)
	logger.Infof("| log-level       	: %-50s |", cfg.LogLevel)

	if cfg.NewRelicAppName != "" && cfg.NewRelicLicense != "" {
		logger.Infof("| newrelic-app-name   : %-50s |", cfg.NewRelicAppName)
		logger.Infof("| newrelic-license    : %-50s |", strings.Repeat("*", len(cfg.NewRelicLicense)))
	}

	// Nomad
	logger.Infof("| nomad-enable     	: %-50t |", cfg.NomadEnable)
	if cfg.NomadReadOnly {
		logger.Infof("| nomad-read-only       : %-50s |", "Yes")
	} else {
		logger.Infof("| nomad-read-only       : %-50s |", "No (Hashi-UI can change Nomad state)")
	}
	logger.Infof("| nomad-address         : %-50s |", cfg.NomadAddress)
	logger.Infof("| nomad-ca-cert         : %-50s |", cfg.NomadCACert)
	logger.Infof("| nomad-client-cert     : %-50s |", cfg.NomadClientCert)
	logger.Infof("| nomad-client-key      : %-50s |", cfg.NomadClientKey)
<commit_msg>Adding startLogging for nomad-skip-verify<commit_after>package main

import (
	"flag"
	"fmt"
	"net/http"
	"os"
	"strconv"
	"strings"
	"time"

	"github.com/gorilla/mux"
	"github.com/newrelic/go-agent"
	"github.com/op/go-logging"
)

var logger = logging.MustGetLogger("hashi-ui")
var defaultConfig = DefaultConfig()

func startLogging(logLevel string) {
	logBackend := logging.NewLogBackend(os.Stderr, "", 0)

	format := logging.MustStringFormatter(
		`%{color}%{time:15:04:05.000} %{shortfile} ▶ %{level:.5s} %{color:reset} %{message}`,
	)
	logBackendFormatted := logging.NewBackendFormatter(logBackend, format)

	logBackendFormattedAndLeveled := logging.AddModuleLevel(logBackendFormatted)

	realLogLevel, err := logging.LogLevel(strings.ToUpper(logLevel))
	if err != nil {
		fmt.Printf("%s (%s)", err, logLevel)
		os.Exit(1)
	}

	logBackendFormattedAndLeveled.SetLevel(realLogLevel, "")

	logging.SetBackend(logBackendFormattedAndLeveled)
}

// Parse the env and cli flags and store the outcome in a Config struct
func (c *Config) Parse() {
	flag.Parse()

	ParseAppEnvConfig(c)
	ParseAppFlagConfig(c)

	ParseNomadEnvConfig(c)
	ParseNomadFlagConfig(c)

	ParseConsulEnvConfig(c)
	ParseConsulFlagConfig(c)

	ParseNewRelicConfig(c)
}

func main() {
	cfg := DefaultConfig()
	cfg.Parse()

	config := newrelic.NewConfig(cfg.NewRelicAppName, cfg.NewRelicLicense)
	config.Logger = newrelic.NewLogger(os.Stdout)

	if cfg.NewRelicAppName == "" || cfg.NewRelicLicense == "" {
		config.Enabled = false
	}

	_, err := newrelic.NewApplication(config)
	if err != nil {
		logger.Error(err)
		os.Exit(1)
	}

	startLogging(cfg.LogLevel)

	logger.Infof("-----------------------------------------------------------------------------")
	logger.Infof("|                             NOMAD UI                                      |")
	logger.Infof("-----------------------------------------------------------------------------")
	logger.Infof("| listen-address  	: http://%-43s |", cfg.ListenAddress)
	logger.Infof("| proxy-address   	: %-50s |", cfg.ProxyAddress)
	logger.Infof("| log-level       	: %-50s |", cfg.LogLevel)

	if cfg.NewRelicAppName != "" && cfg.NewRelicLicense != "" {
		logger.Infof("| newrelic-app-name   : %-50s |", cfg.NewRelicAppName)
		logger.Infof("| newrelic-license    : %-50s |", strings.Repeat("*", len(cfg.NewRelicLicense)))
	}

	// Nomad
	logger.Infof("| nomad-enable     	: %-50t |", cfg.NomadEnable)
	if cfg.NomadReadOnly {
		logger.Infof("| nomad-read-only       : %-50s |", "Yes")
	} else {
		logger.Infof("| nomad-read-only       : %-50s |", "No (Hashi-UI can change Nomad state)")
	}
	logger.Infof("| nomad-address         : %-50s |", cfg.NomadAddress)
	logger.Infof("| nomad-ca-cert         : %-50s |", cfg.NomadCACert)
	logger.Infof("| nomad-client-cert     : %-50s |", cfg.NomadClientCert)
	logger.Infof("| nomad-client-key      : %-50s |", cfg.NomadClientKey)
	logger.Infof("| nomad-skip-verify   	: %-50t |", cfg.NomadSkipVerify)
	if cfg.NomadSkipVerify {
		logger.Infof("| nomad-skip-verify     : %-50s |", "Yes")
	} else {
		logger.Infof("| nomad-skip-verify     : %-50s |", "No")
	}

{'fraction_non_alphanumeric': 0.2094742146816731, 'fraction_numerical': 0.013438602385351923, 'mean_word_length': 2.943046357615894, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4352581', 'n_tokens_mistral': 2253, 'n_tokens_neox': 2150, 'n_words': 350}