logging

package module
v0.0.0-...-778551a Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

README

logging

A simple logging tool

介绍
  1. 在每天0点分割前天的日志为单独的文件,并以日期+.log为文件名后缀,然后删除两个月以前的日志文件。
  2. 每月1日0点30分,对上个月的日志文件以tar.gz进行打包压缩。
安装教程
  1. go get github.com/Jerryhax/logging
使用说明
  1. 依赖 github.com/cobfig/cron/v3
参与贡献

欢迎提交issues

  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request

Documentation

Overview

@Description: TODO

@Description: 对log file 进行维护: 1,在每天0点分割前天的日志为单独的文件,并以日期+.log为文件名后缀,然后删除两个月以前的日志文件。 2,每月1日0点30分,对上个月的日志文件以tar.gz进行打包压缩。

Index

Constants

This section is empty.

Variables

View Source
var (
	L Logger

	DefaultPrefix      = ""
	DefaultCallerDepth = 2

	LogRootPath = "runtime/"
	TimeFormat  = "2006-01-02"
	LogFileExt  = "log"
	//每日0点0分重命名前一天的日志文件
	CronEveryday = "0 0 0 * * ?"
	//每月一日0点30分执行压缩打包
	CronEveryMonth = "0 30 0 1 * ?"
)

Functions

func CheckNotExist

func CheckNotExist(src string) bool

func CheckPermission

func CheckPermission(src string) bool

func Debug

func Debug(v ...interface{})

func Debugf

func Debugf(format string, v ...interface{})

func Error

func Error(v ...interface{})

func Errorf

func Errorf(format string, v ...interface{})

func Fatal

func Fatal(v ...interface{})

func Fatalf

func Fatalf(format string, v ...interface{})

func GetExt

func GetExt(fileName string) string

func GetSize

func GetSize(f multipart.File) (int, error)

func Info

func Info(v ...interface{})

func Infof

func Infof(format string, v ...interface{})

func IsNotExistMkDir

func IsNotExistMkDir(src string) error

func Maintain

func Maintain()

func MkDir

func MkDir(src string) error

func MustOpen

func MustOpen(fileName, filePath string) (*os.File, error)

func Open

func Open(name string, flag int, perm os.FileMode) (*os.File, error)

func Setup

func Setup(filePath, fileName string)

func Warn

func Warn(v ...interface{})

func Warnf

func Warnf(format string, v ...interface{})

Types

type Level

type Level int
const (
	DEBUG Level = iota
	INFO
	WARNING
	ERROR
	FATAL
)

type Logger

type Logger struct {
	//lock. when maintaining, cannot write
	sync.RWMutex
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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