<commit_before>package logger

import (
	"os"
	"strconv"

	"github.com/Sirupsen/logrus"
	"github.com/polds/logrus/hooks/papertrail"
)

var __l *logrus.Logger

type Config struct {
	Appname string
	Host    string
	Port    int
}

type Client struct {
	*logrus.Logger
}

// Logger returns an instance of
// a logger or creates a new one.
func Logger() *logrus.Logger {
	if __l == nil {
		__l = NewLogger()
	}

	return __l
}

// New creates a new instance of a
// logger based on provided config data
func New(config Config) Client {
	var client Client

	client.Logger = logrus.New()
	hook, err := logrus_papertrail.NewPapertrailHook(config.Host, config.Port, config.Appname)
	hook.UseHostname()

	// Register the PaperTrail hook
	if err == nil {
		client.Logger.Hooks.Add(hook)
	}

	return client
}

// DefaultConfig makes certain assumptions about your environment variables
// and can be used to create a new basic instance.
func DefaultConfig() Config {
	app := os.Getenv("APPNAME")
	if app == "" {
		app, _ = os.Hostname()
		os.Setenv("APPNAME", app)
	}

	port, _ := strconv.Atoi(os.Getenv("PAPERTRAIL_PORT"))
	return Config{
		Appname: os.Getenv("APPNAME"),
		Host:    os.Getenv("PAPERTRAIL_HOST"),
		Port:    port,
	}
}

// @TODO polds deprecate this function
func NewLogger() *logrus.Logger {
	return New(DefaultConfig()).Logger
}<commit_msg>No need to reset the env<commit_after>package logger

import (
	"os"
	"strconv"

	"github.com/Sirupsen/logrus"
	"github.com/polds/logrus/hooks/papertrail"
)

var __l *logrus.Logger

type Config struct {
	Appname string
	Host    string
	Port    int
}

type Client struct {
	*logrus.Logger
}

// Logger returns an instance of
// a logger or creates a new one.
func Logger() *logrus.Logger {
	if __l == nil {
		__l = NewLogger()
	}

	return __l
}

// New creates a new instance of a
// logger based on provided config data
func New(config Config) Client {
	var client Client

	client.Logger = logrus.New()
	hook, err := logrus_papertrail.NewPapertrailHook(config.Host, config.Port, config.Appname)
	hook.UseHostname()

	// Register the PaperTrail hook
	if err == nil {
		client.Logger.Hooks.Add(hook)
	}

	return client
}

// DefaultConfig makes certain assumptions about your environment variables
// and can be used to create a new basic instance.
func DefaultConfig() Config {
	app := os.Getenv("APPNAME")
	if app == "" {
		app, _ = os.Hostname()
	}

	port, _ := strconv.Atoi(os.Getenv("PAPERTRAIL_PORT"))
	return Config{
		Appname: app,
		Host:    os.Getenv("PAPERTRAIL_HOST"),
		Port:    port,
	}
}

// @TODO polds deprecate this function
func NewLogger() *logrus.Logger {
	return New(DefaultConfig()).Logger
}
{'fraction_non_alphanumeric': 0.11700526711813393, 'fraction_numerical': 0.0, 'mean_word_length': 3.6486013986013988, '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': '2159715', 'n_tokens_mistral': 953, 'n_tokens_neox': 924, 'n_words': 267}