<commit_before>// Copyright (c) 2015, huangjunwei <<EMAIL>>. All rights reserved.

package blog4go

import (
	"testing"
	"time"
)

type MyHook struct {
	cnt     int
	level   Level
	message string
}

func (self *MyHook) add() {
	self.cnt++
}

func (self *MyHook) Fire(level Level, message string) {
	self.add()
	self.level = level
	self.message = message
}

func TestHook(t *testing.T) {
	hook := new(MyHook)
	hook.cnt = 0

	err := NewFileWriter("/tmp", false)
	defer blog.Close()
	if nil != err {
		t.Errorf("initialize file writer faied. err: %s", err.Error())
	}

	blog.SetHook(hook)
	blog.SetHookLevel(INFO)

	blog.Trace("something")
	// wait for hook called
	time.Sleep(10 * time.Millisecond)
	if 0 != hook.cnt {
		t.Error("hook called not valid")
	}

	if TRACE == hook.level || "something" == hook.message {
		t.Errorf("hook parameters wrong. level: %d, message: %s", hook.level, hook.message)
	}

	blog.Info("yes")
	// wait for hook called
	time.Sleep(10 * time.Millisecond)
	if 1 != hook.cnt {
		t.Error("hook not called")
	}

	if INFO != hook.level || "yes" != hook.message {
		t.Errorf("hook parameters wrong. level: %d, message: %s", hook.level, hook.message)
	}
}
<commit_msg>fix golint<commit_after>// Copyright (c) 2015, huangjunwei <<EMAIL>>. All rights reserved.

package blog4go

import (
	"testing"
	"time"
)

type MyHook struct {
	cnt     int
	level   Level
	message string
}

func (hook *MyHook) add() {
	hook.cnt++
}

func (hook *MyHook) Fire(level Level, message string) {
	hook.add()
	hook.level = level
	hook.message = message
}

func TestHook(t *testing.T) {
	hook := new(MyHook)
	hook.cnt = 0

	err := NewFileWriter("/tmp", false)
	defer blog.Close()
	if nil != err {
		t.Errorf("initialize file writer faied. err: %s", err.Error())
	}

	blog.SetHook(hook)
	blog.SetHookLevel(INFO)

	blog.Trace("something")
	// wait for hook called
	time.Sleep(10 * time.Millisecond)
	if 0 != hook.cnt {
		t.Error("hook called not valid")
	}

	if TRACE == hook.level || "something" == hook.message {
		t.Errorf("hook parameters wrong. level: %d, message: %s", hook.level, hook.message)
	}

	blog.Info("yes")
	// wait for hook called
	time.Sleep(10 * time.Millisecond)
	if 1 != hook.cnt {
		t.Error("hook not called")
	}

	if INFO != hook.level || "yes" != hook.message {
		t.Errorf("hook parameters wrong. level: %d, message: %s", hook.level, hook.message)
	}
}

{'fraction_non_alphanumeric': 0.16026992830029524, 'fraction_numerical': 0.010122311261071278, 'mean_word_length': 3.5615384615384613, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '288074', 'n_tokens_mistral': 915, 'n_tokens_neox': 866, 'n_words': 239}