Documentation ¶
Index ¶
- Constants
- Variables
- func ArchiveGzipFile(srcFile string) error
- func CopyFile(dest, source string) error
- func EnsureBaseDir(baseDir, path string) string
- func IsFileExist(filename string) bool
- func LockFile(f *os.File) error
- func ReadFileToLines(filename string) ([]string, error)
- func ReadToLines(rd io.Reader) ([]string, error)
- func UniqueDirectory(path, name string) (string, error)
- func UnlockFile(f *os.File) error
- type FileWriter
Constants ¶
View Source
const ( DefaultMaxBytesPerFile = 1024 * 1024 * 20 // 20M FlushInterval = 10 // 10ms )
Variables ¶
View Source
var (
ErrCannotRotateFile = errors.New("cannot create rotate file")
)
Functions ¶
func EnsureBaseDir ¶
EnsureBaseDir ensures that path is always prefixed by baseDir, allowing for the fact that path might have a Window drive letter in it.
func UniqueDirectory ¶
UniqueDirectory returns "path/name" if that directory doesn't exist. If it does, the method starts appending .1, .2, etc until a unique name is found.
func UnlockFile ¶
Types ¶
type FileWriter ¶
type FileWriter struct {
// contains filtered or unexported fields
}
FileWriter with log-rotation and auto-archive
func NewFileWriter ¶
func NewFileWriter(name string, maxBytesPerFile int) *FileWriter
func (*FileWriter) Close ¶
func (w *FileWriter) Close()
func (*FileWriter) Flush ¶
func (w *FileWriter) Flush() error
func (*FileWriter) Init ¶
func (w *FileWriter) Init() error
Click to show internal directories.
Click to hide internal directories.