rotate

package
v7.6.5 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2025 License: MIT Imports: 7 Imported by: 1

Documentation

Overview

Package rotate 提供一个可以按文件大小进行分割的 io.Writer 实例

import "log"
// 每个文件以 100M 大小进行分割,以日期名作为文件名保存在 /var/log 下。
f,_ := New("debug-200601%i", "/var/log", 100*1024*1024)
l := log.New(f, "DEBUG", log.LstdFlags)

Index

Constants

This section is empty.

Variables

View Source
var ErrIndexNotExists = errors.New("必须存在 %i")

ErrIndexNotExists 格式化字符串 %i 不存在

Functions

func New

func New(format, dir string, size int64) (io.WriteCloser, error)

New 声明按大小进行文件分割的对象

format 文件名格式,除了标准库支持的时间格式之外,还需要包含 %i 占位符,表示同一时间段内的产生多个文件时的计数器。比如:

2006-01-02-15-04-%i-01-02.log

dir 为文件保存的目录,若不存在会尝试创建。 size 为每个文件的最大尺寸,单位为 byte。

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳