<commit_before>package reactLog_test

import (
	"bytes"
	"fmt"
	"io/ioutil"
	"log"
	"os"

	"github.com/MatejB/reactLog"
)

func ExampleDiscard() {
	reactLogger := reactLog.New(os.Stdout) // use os.Stderr for default log functionality
	reactLogger.AddReaction("INFO", &reactLog.Discard{})

	logger := log.New(reactLogger, "", 0)
	logger.Println("INFO this will NOT be written")
	logger.Println("ERROR this will be written")
	// Output: ERROR this will be written
}

func ExampleRedirect() {
	logContainerForUser107 := &bytes.Buffer{} // it can be any io.Writer eq. file

	reactLogger := reactLog.New(ioutil.Discard) // use os.Stderr for default log functionality
	reactLogger.AddReaction("USER_107", &reactLog.Redirect{logContainerForUser107})

	logger := log.New(reactLogger, "", 0)

	logger.Println("INFO dummy log 1")
	logger.Println("ERROR dummy log 2")

	logger.Println("Log concerning USER_107 with extra data")

	logger.Println("INFO dummy log 3")
	logger.Println("ERROR dummy log 4")

	fmt.Println(logContainerForUser107)
	// Output: Log concerning USER_107 with extra data
}

func ExampleCopy() {
	logContainerForUser107 := &bytes.Buffer{} // it can be any io.Writer eq. file

	reactLogger := reactLog.New(os.Stdout) // use os.Stderr for default log functionality
	reactLogger.AddReaction("USER_107", &reactLog.Copy{logContainerForUser107})

	logger := log.New(reactLogger, "", 0)

	logger.Println("Log concerning USER_107 with extra data")
	logger.Println("INFO dummy log")

	fmt.Println(logContainerForUser107) // in logContainerForUser107 is copy of log just for USER_107
	// Output:
	// Log concerning USER_107 with extra data
	// INFO dummy log
	// Log concerning USER_107 with extra data
}<commit_msg>examples for copy & redirect updated<commit_after>package reactLog_test

import (
	"bytes"
	"fmt"
	"io/ioutil"
	"log"
	"os"

	"github.com/MatejB/reactLog"
)

func ExampleDiscard() {
	reactLogger := reactLog.New(os.Stdout) // use os.Stderr for default log functionality
	reactLogger.AddReaction("INFO", &reactLog.Discard{})

	logger := log.New(reactLogger, "", 0)
	logger.Println("INFO this will NOT be written")
	logger.Println("ERROR this will be written")
	// Output: ERROR this will be written
}

func ExampleRedirect() {
	logContainerForUser107 := &bytes.Buffer{} // it can be any io.Writer eq. file

	reactLogger := reactLog.New(ioutil.Discard) // use os.Stderr for default log functionality
	reactLogger.AddReaction("user ID 107", &reactLog.Redirect{logContainerForUser107})

	logger := log.New(reactLogger, "", 0)

	logger.Println("INFO dummy log 1")
	logger.Println("ERROR dummy log 2")

	logger.Println("Log concerning user ID 107 with extra data")

	logger.Println("INFO dummy log 3")
	logger.Println("ERROR dummy log 4")

	fmt.Println(logContainerForUser107)
	// Output: Log concerning user ID 107 with extra data
}

func ExampleCopy() {
	logContainerForUser107 := &bytes.Buffer{} // it can be any io.Writer eq. file

	reactLogger := reactLog.New(os.Stdout) // use os.Stderr for default log functionality
	reactLogger.AddReaction("user ID 107", &reactLog.Copy{logContainerForUser107})

	logger := log.New(reactLogger, "", 0)

	logger.Println("Log concerning user ID 107 with extra data")
	logger.Println("INFO dummy log")

	fmt.Println(logContainerForUser107) // in logContainerForUser107 is copy of log just for USER_107
	// Output:
	// Log concerning user ID 107 with extra data
	// INFO dummy log
	// Log concerning user ID 107 with extra data
}
{'fraction_non_alphanumeric': 0.11830742659758203, 'fraction_numerical': 0.029936672423719057, 'mean_word_length': 4.659609120521172, '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': '716211', 'n_tokens_mistral': 1203, 'n_tokens_neox': 1095, 'n_words': 326}