gorotator

package module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2019 License: MIT Imports: 9 Imported by: 0

README

gorotator

The small library for a file rotation. Zero dependencies, only standart library.

Quick start

package main

import (
	"fmt"
	"github.com/BoRuDar/gorotator"
)

func main() {
	fr, err := gorotator.New(gorotator.Config{
		PathToDir:        "./testdir",
		FileName:         "file.log",
		MaxFileSize:      1 * gorotator.KB,
		MaxNumberOfFiles: 3,
		IsWindows:        true,
	})
	if err != nil {
		panic(err)
	}
	defer fr.Close()

	_, err = fmt.Fprintln(fr, "test")
	if err != nil {
		panic(err)
	}
}


Documentation

Index

Constants

View Source
const (
	KB int64 = 1024
	MB       = KB * 1024
	GB       = MB * 1024
)

Variables

This section is empty.

Functions

func New

func New(cfg Config) (io.WriteCloser, error)

Types

type Config

type Config struct {
	FileName         string
	PathToDir        string
	MaxFileSize      int64 // in bytes
	MaxNumberOfFiles int
	IsWindows        bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL