<commit_before>// Copyright 2014 The Sporting Exchange Limited. All rights reserved.
// Use of this source code is governed by a free license that can be
// found in the LICENSE file.

// Package config handles the config file.
package config

import (
	"encoding/json"
	"flag"
	"fmt"
	"io"
	"log"
	"os"

	"opentsp.org/cmd/collect-statse/aggregator"
	"opentsp.org/cmd/collect-statse/forwarder"
	"opentsp.org/cmd/collect-statse/statse"

	"opentsp.org/internal/tsdb"
	"opentsp.org/internal/tsdb/filter"
	"opentsp.org/internal/version"

	xconfig "opentsp.org/internal/config"
)

const maxRules = 64

var Loaded *Config

func Load(tsdbChan chan<- *tsdb.Point) {
	var (
		filePath    = flag.String("f", "/etc/collect-statse/config", "configuration file")
		debugMode   = flag.Bool("v", false, "verbose mode")
		testMode    = flag.Bool("t", false, "configuration test")
		VersionMode = flag.Bool("version", false, "output version and exit")
	)
	flag.Parse()
	log.SetFlags(0)
	if flag.NArg() != 0 {
		flag.Usage()
		os.Exit(1)
	}
	if *VersionMode {
		fmt.Println(version.ToString())
		os.Exit(0)
	}
	if *debugMode {
		w := os.Stderr
		xconfig.Debug = log.New(w, "debug: config: ", 0)
		statse.Debug = log.New(w, "debug: statse: ", 0)
		forwarder.Debug = log.New(w, "debug: forwarder: ", 0)
		filter.Debug = log.New(w, "debug: forwarder/filter: ", 0)
		aggregator.Debug = log.New(w, "debug: aggregator: ", 0)
	}
	config := new(Config)
	xconfig.Load(config, *filePath, "collect-statse?host={{.Hostname}}")
	if *testMode {
		config.Dump(os.Stdout)
		os.Exit(0)
	}
	Loaded = config<commit_msg>Change var for consistency with surronding code<commit_after>// Copyright 2014 The Sporting Exchange Limited. All rights reserved.
// Use of this source code is governed by a free license that can be
// found in the LICENSE file.

// Package config handles the config file.
package config

import (
	"encoding/json"
	"flag"
	"fmt"
	"io"
	"log"
	"os"

	"opentsp.org/cmd/collect-statse/aggregator"
	"opentsp.org/cmd/collect-statse/forwarder"
	"opentsp.org/cmd/collect-statse/statse"

	"opentsp.org/internal/tsdb"
	"opentsp.org/internal/tsdb/filter"
	"opentsp.org/internal/version"

	xconfig "opentsp.org/internal/config"
)

const maxRules = 64

var Loaded *Config

func Load(tsdbChan chan<- *tsdb.Point) {
	var (
		filePath    = flag.String("f", "/etc/collect-statse/config", "configuration file")
		debugMode   = flag.Bool("v", false, "verbose mode")
		testMode    = flag.Bool("t", false, "configuration test")
		versionMode = flag.Bool("version", false, "output version and exit")
	)
	flag.Parse()
	log.SetFlags(0)
	if flag.NArg() != 0 {
		flag.Usage()
		os.Exit(1)
	}
	if *versionMode {
		fmt.Println(version.ToString())
		os.Exit(0)
	}
	if *debugMode {
		w := os.Stderr
		xconfig.Debug = log.New(w, "debug: config: ", 0)
		statse.Debug = log.New(w, "debug: statse: ", 0)
		forwarder.Debug = log.New(w, "debug: forwarder: ", 0)
		filter.Debug = log.New(w, "debug: forwarder/filter: ", 0)
		aggregator.Debug = log.New(w, "debug: aggregator: ", 0)
	}
	config := new(Config)
	xconfig.Load(config, *filePath, "collect-statse?host={{.Hostname}}")
	if *testMode {
		config.Dump(os.Stdout)
		os.Exit(0)
	}
	Loaded = config
{'fraction_non_alphanumeric': 0.158223889931207, 'fraction_numerical': 0.010006253908692933, 'mean_word_length': 3.8989280245022973, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1193694', 'n_tokens_mistral': 1280, 'n_tokens_neox': 1209, 'n_words': 277}