logrotate

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2021 License: MIT Imports: 11 Imported by: 2

README

Log rotation package for Go

GoDoc

This package provides automatic log rotation for servers

Installation

Use the go command:

$ go get github.com/rclancey/logrotate

Example

package main

import (
    "log"
    "time"
)

func init() {
    logFn := "/var/log/myServer/errors.log"
    rotationPeriod := 24 * time.Hour
    maxSize := 0
    retainCount := 7
    rotlog, err := logrotate.Open(logFn, rotationPeriod, maxSize, retainCount)
    log.SetOutput(rotlog)
}

Documentation

Documentation is hosted at GoDoc project.

Copyright (C) 2019-2020 by Ryan Clancey

Package released under MIT License. See LICENSE for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RotateFile

type RotateFile struct {
	// contains filtered or unexported fields
}

func Open

func Open(fn string, maxAge time.Duration, maxSize int64, count int) (*RotateFile, error)

func (*RotateFile) Close

func (l *RotateFile) Close() error

func (*RotateFile) MaxAge

func (l *RotateFile) MaxAge() time.Duration

func (*RotateFile) MaxBackups

func (l *RotateFile) MaxBackups() int

func (*RotateFile) MaxSize

func (l *RotateFile) MaxSize() int64

func (*RotateFile) Name

func (l *RotateFile) Name() string

func (*RotateFile) Rotate

func (l *RotateFile) Rotate() error

func (*RotateFile) SetMaxAge

func (l *RotateFile) SetMaxAge(age time.Duration)

func (*RotateFile) SetMaxBackups

func (l *RotateFile) SetMaxBackups(count int)

func (*RotateFile) SetMaxSize

func (l *RotateFile) SetMaxSize(size int64)

func (*RotateFile) SetTimeZone

func (l *RotateFile) SetTimeZone(tz *time.Location)

func (*RotateFile) TimeZone

func (l *RotateFile) TimeZone() *time.Location

func (*RotateFile) Write

func (l *RotateFile) Write(data []byte) (int, error)

Jump to

Keyboard shortcuts

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