z1log

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: Apache-2.0 Imports: 9 Imported by: 1

README

z1log

介绍

开箱即用,轻量的日志,基于标准 log 库,实现日志分级输出到各种的文件,而且支持按每年,每月,每日,每小时,每分钟,每周拆分日志文件。

软件架构

软件架构说明

安装教程
  1. go get gitee.com/z1gotool/z1log
  2. xxxx
  3. xxxx
使用说明

z1log.Debug("This is a debug message")
z1log.Debugf("This is a debug message,time:%v",time.Now())
z1log.Info,z1log.Infof
z1log.Warning,z1log.Warningf
z1log.Error,z1log.Errorf


设置日志,不设置也可以用,只有默认值输出到控制台
z1log.SetLog(
    z1log.DEBUG, //输出日志级别,级别小于个级别的都会输出
    "logs/app.log", //文件输出路径和名称,为空标识不输出文件
    z1log.EveryMinute, //安装每分钟拆分文件
    false, //不按日志等级拆分文件
)

参与贡献
  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request
特技
  1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
  2. Gitee 官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解 Gitee 上的优秀开源项目
  4. GVP 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
  5. Gitee 官方提供的使用手册 https://gitee.com/help
  6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 https://gitee.com/gitee-stars/

Documentation

Index

Constants

View Source
const (
	DEBUG = iota + 1
	INFO
	WARNING
	ERROR
	ALL = 735
)
View Source
const (
	EveryYear = iota + 1
	EveryMonth
	EveryDay
	EveryWeek
	EveryHour
	EveryMinute
)

Variables

This section is empty.

Functions

func Debug

func Debug(message ...any)

func Debugf

func Debugf(format string, message ...any)

func Error

func Error(message ...any)

func Errorf

func Errorf(format string, message ...any)

func Info

func Info(message ...any)

func Infof

func Infof(format string, message ...any)

func SetLog

func SetLog(level int, fileName string, splitTime int, splitLevel bool)

SetLog(DEBUG, "logs/app.log", EveryYear, true) // Output to files and console, split files by date and log level SetLog(DEBUG, "logs/app.log", EveryYear, false) // Output to files and console, only split files by date SetLog(DEBUG, "", EveryYear, false) // Only output to the console

func Warning

func Warning(message ...any)

func Warningf

func Warningf(format string, message ...any)

Types

type Logger

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

func NewLogger

func NewLogger(level int, fileName string, splitTime int, splitLevel bool) *Logger

func (*Logger) Close

func (l *Logger) Close()

func (*Logger) Printf

func (l *Logger) Printf(level int, format string, message ...any)

func (*Logger) Println

func (l *Logger) Println(level int, message ...any)

Directories

Path Synopsis
test
rs

Jump to

Keyboard shortcuts

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