Help us shape the future of Go! Take the 2026 Go Developer Survey

logfox

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2019 License: Apache-2.0 Imports: 8 Imported by: 1

README

logfox

简介

logfox是一个简单的go log库,可以按小时自动切分日志,设置日志保存的期限

V1.1使用go mod做依赖管理

安装

go get github.com/zer0131/logfox

使用示例

package main

import "github.com/zer0131/logfox"

func init() {
    logfox.Init("./log", "test", "DEBUG", 7)
}

func main() {
    logfox.Info("test info")
    logfox.Close()
}

Documentation

Index

Constants

View Source
const (
	DEFAULT_FILEWRITER_MAX_EXPIRE_DAY          = 7                       //日志默认有效天数
	DEFAULT_FILEWRITER_FILE_SUFFIX_TIME_STRING = "2006010215"            //日志文件时间前缀
	DEFAULT_FILEWRITER_MSG_SUFFIX_TIME_STRING  = "06-01-02 15:04:05.999" //日志时间格式
)

Variables

This section is empty.

Functions

func Close

func Close()

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 Info

func Info(v ...interface{})

func Infof

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

func Init

func Init(path string, app string, level string, expireDay int) error

日志初始化

func Notice

func Notice(v ...interface{})

func Noticef

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

func Panic

func Panic(v ...interface{})

func Panicf

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

func Warn

func Warn(v ...interface{})

func Warnf

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

Types

type Level

type Level uint8

别名

const (
	DebugLevel Level = iota
	InfoLevel
	NoticeLevel
	WarnLevel
	ErrorLevel
	PanicLevel
)

级别常量

func (Level) String

func (l Level) String() string

实现String方法,输出时默认转换为字符串

type Logger

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

func NewLogger

func NewLogger(path string, app string, expireDay int, fileSuffixTimeString string) (*Logger, error)

func (*Logger) Close

func (lo *Logger) Close()

func (*Logger) Output

func (lo *Logger) Output(msg string, level Level)

正常输出

func (*Logger) OutputWf

func (lo *Logger) OutputWf(msg string, level Level)

错误输出

type Writer

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

func NewWriter

func NewWriter(path string, fileName string, fileSuffixTimeString string, expireDay int) (*Writer, error)

func (*Writer) Close

func (w *Writer) Close()

Jump to

Keyboard shortcuts

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