<commit_before>// Copyright 2015, <NAME>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package store

import (
	"io"
	"log"
	"net/http"
)

// LogFileSystem returns a wrapper around an http.FileSystem which logs calls
// to Open.
func LogFileSystem(prefix string, fs http.FileSystem) http.FileSystem {
	return logFileSystem{
		FileSystem: fs,
		prefix:     prefix,
	}
}

type logFileSystem struct {
	http.FileSystem
	prefix string
}

func (l logFileSystem) Open(path string) (http.File, error) {
	f, err := l.FileSystem.Open(path)
	if err != nil {
		log.Printf("%v open error: %v (%v)", l.prefix, path, err)
		return nil, err
	}
	log.Printf("%v open: %v", l.prefix, path)
	return f, err
}

// LogRWFileSystem returns a wrapper around a RWFileSystem which logs calls
// to Open and Create.
func LogRWFileSystem(prefix string, fs RWFileSystem) RWFileSystem {
	return logRWFileSystem{
		RWFileSystem: fs,
		prefix:       prefix,
	}
}

type logRWFileSystem struct {
	RWFileSystem
	prefix string
}

func (l logRWFileSystem) Open(path string) (http.File, error) {
	log.Printf("%v open: %v", l.prefix, path)
	return l.RWFileSystem.Open(path)
}

func (l logRWFileSystem) Create(path string) (io.WriteCloser, error) {
	log.Printf("%v create: %v", l.prefix, path)
	return l.RWFileSystem.Create(path)<commit_msg>Update logging filesystems to use log.Logger.<commit_after>// Copyright 2015, <NAME>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package store

import (
	"io"
	"log"
	"net/http"
	"os"
)

// LogFileSystem returns a wrapper around an http.FileSystem which logs calls
// to Open.
func LogFileSystem(prefix string, fs http.FileSystem) http.FileSystem {
	if prefix != "" {
		prefix += " "
	}
	return logFileSystem{
		FileSystem: fs,
		Logger:     log.New(os.Stderr, prefix, log.LstdFlags),
	}
}

type logFileSystem struct {
	http.FileSystem
	*log.Logger
}

// Open implements http.FileSystem.
func (l logFileSystem) Open(path string) (http.File, error) {
	f, err := l.FileSystem.Open(path)
	if err != nil {
		l.Printf("open error: %v", err)
		return nil, err
	}
	l.Printf("open: %v", path)
	return f, err
}

// LogRWFileSystem returns a wrapper around a RWFileSystem which logs calls
// to Open and Create.
func LogRWFileSystem(prefix string, fs RWFileSystem) RWFileSystem {
	if prefix != "" {
		prefix += " "
	}
	return logRWFileSystem{
		RWFileSystem: fs,
		Logger:       log.New(os.Stderr, prefix, log.LstdFlags),
	}
}

type logRWFileSystem struct {
	RWFileSystem
	*log.Logger
}

// Open implements RWFileSystem.
func (l logRWFileSystem) Open(path string) (http.File, error) {
	f, err := l.RWFileSystem.Open(path)
	if err != nil {
		l.Printf("open error: %v", err)
		return nil, err
	}
	l.Printf("open: %v", path)
	return f, err
}

// Create implements RWFileSystem.
func (l logRWFileSystem) Create(path string) (io.WriteCloser, error) {
	f, err := l.RWFileSystem.Create(path)
	if err != nil {
		l.Printf("create error: %v", err)
	}
	l.Printf("create: %v", path)
	return f, err
{'fraction_non_alphanumeric': 0.12633279483037158, 'fraction_numerical': 0.002584814216478191, 'mean_word_length': 3.8450704225352115, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5779329', 'n_tokens_mistral': 1113, 'n_tokens_neox': 1095, 'n_words': 339}