<commit_before>package logtap

import "fmt"
import "github.com/nanobox-core/hatchet"

type Publisher interface {
	Publish(tags []string, data string)
}

type PublishDrain struct {
	log       hatchet.Logger
	publisher Publisher
}

// NewPublishDrain creates a new publish drain and returns it
func NewPublishDrain(pub Publisher) *PublishDrain {
	return &PublishDrain{
		publisher: pub,
	}
}

// SetLogger really allows the logtap main struct
// to assign its own logger to the publsih drain
// the publsih drain doesnt use the logger but
// it is necessary to have the method to match the interface
// the assumption here is that the publisher will do its own loggin
func (p *PublishDrain) SetLogger(l hatchet.Logger) {
	p.log = l
}

// Write formats the data coming in on the message and drops it on the publish method
// in a format the publisher can use
func (p *PublishDrain) Write(msg Message) {
	p.publisher.Publish([]string{"log"}, fmt.Sprintf("[%s] %s", msg.Time, msg.Content))
}
<commit_msg>add a little logging to the publsih drain<commit_after>package logtap

import "fmt"
import "github.com/nanobox-core/hatchet"

type Publisher interface {
	Publish(tags []string, data string)
}

type PublishDrain struct {
	log       hatchet.Logger
	publisher Publisher
}

// NewPublishDrain creates a new publish drain and returns it
func NewPublishDrain(pub Publisher) *PublishDrain {
	return &PublishDrain{
		publisher: pub,
	}
}

// SetLogger really allows the logtap main struct
// to assign its own logger to the publsih drain
// the publsih drain doesnt use the logger but
// it is necessary to have the method to match the interface
// the assumption here is that the publisher will do its own loggin
func (p *PublishDrain) SetLogger(l hatchet.Logger) {
	p.log = l
}

// Write formats the data coming in on the message and drops it on the publish method
// in a format the publisher can use
func (p *PublishDrain) Write(msg Message) {
	log.Info("Publishing:[%s] %s", msg.Time, msg.Content)
	p.publisher.Publish([]string{"log"}, fmt.Sprintf("[%s] %s", msg.Time, msg.Content))
}

{'fraction_non_alphanumeric': 0.0913022585295531, 'fraction_numerical': 0.0, 'mean_word_length': 4.17910447761194, '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': '4691954', 'n_tokens_mistral': 660, 'n_tokens_neox': 646, 'n_words': 259}