logrotate

package module
v4.0.6 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: MIT Imports: 11 Imported by: 1

README

LogRotate插件

可以实时查看日志输出,和日志查询 日志查询暂时只支持linux系统

插件地址

https://github.com/Monibuca/plugin-logrotate

插件引入

import (
    _ "m7s.live/plugin/logrotate/v4"
)

默认配置

logrotate:
 path: ./logs # 生成日志的目录
 size: 0 # 每个日志文件的大小,单位字节,0表示不限制
 days: 1 # 按时间分割,单位是天,即24小时
 formatter : 2006-01-02T15 # 日志文件名格式化,按照go layout格式化,默认按照小时

API接口

GET logrotate/api/tail

监听日志输出,该请求是一个SSE(server-sent Event)

GET logrotate/api/find

查找日志,目前只支持linux系统(使用grep),参数为 ?query=xxx,比如 /logrotate/api/find?query=monibuca

GET logrotate/api/list

日志列表,列出所有日志文件

GET logrotate/api/open

打开日志,入参是 ?file=xxxxxx为文件名,文件名来自日志列表中的文件,比如 logrotate/api/open?file=2024-01-23T09.log

GET logrotate/api/download

下载某个日志,入参是?file=xxx,参数同上打开日志

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileInfo

type FileInfo struct {
	Name string
	Size int64
}

type LogRotateConfig

type LogRotateConfig struct {
	Path      string `default:"./logs" desc:"日志文件存放目录"`
	Size      int64  `desc:"日志文件大小,单位:字节"`
	Days      int    `default:"1" desc:"日志文件保留天数"`
	Formatter string `default:"2006-01-02T15" desc:"日志文件名格式"`
	// contains filtered or unexported fields
}

func (*LogRotateConfig) API_download

func (l *LogRotateConfig) API_download(w http.ResponseWriter, r *http.Request)

func (*LogRotateConfig) API_find

func (l *LogRotateConfig) API_find(w http.ResponseWriter, r *http.Request)

func (*LogRotateConfig) API_list

func (l *LogRotateConfig) API_list(w http.ResponseWriter, r *http.Request)

func (*LogRotateConfig) API_open

func (l *LogRotateConfig) API_open(w http.ResponseWriter, r *http.Request)

func (*LogRotateConfig) API_tail

func (l *LogRotateConfig) API_tail(w http.ResponseWriter, r *http.Request)

func (*LogRotateConfig) OnEvent

func (config *LogRotateConfig) OnEvent(event any)

func (*LogRotateConfig) Write

func (l *LogRotateConfig) Write(data []byte) (n int, err error)

Jump to

Keyboard shortcuts

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