zdpgo_log

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2021 License: MIT Imports: 5 Imported by: 15

README

zdpgo_log

Golang日志框架

一、快速入门

1.1 创建日志并记录
package main

import "github.com/zhangdapeng520/zdpgo_log"

func main() {
	log := zdpgo_log.New("zdpgo_log.log")
	log.SetDebug(true) // 开启debug模式
	
	log.Info("info...")
	log.Warning("warning...")
	log.Error("error...")
	log.Panic("panic...")
	
	log.SetDebug(false) // 关闭debug模式
	
	log.Info("info 111...")
	log.Warning("warning 111...")
	log.Error("error 111...")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Log

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

func New

func New(config LogConfig) *Log

创建日志文件对象

func (*Log) Debug

func (l *Log) Debug(msg string, args ...interface{})

记录debug类型的日志

func (*Log) Error

func (l *Log) Error(msg string, args ...interface{})

记录error类型的日志

func (*Log) Info

func (l *Log) Info(msg string, args ...interface{})

记录info类型的日志

func (*Log) Panic

func (l *Log) Panic(msg string, args ...interface{})

记录panic类型的日志,会panic出异常

func (*Log) SetDebug

func (l *Log) SetDebug(debug bool)

设置日志的debug模式

func (*Log) SetDebug1 added in v1.1.0

func (l *Log) SetDebug1(flag bool)

func (*Log) SetPath added in v1.0.2

func (log *Log) SetPath(path string)

设置日志的存储路径

func (*Log) Warning

func (l *Log) Warning(msg string, args ...interface{})

记录warning类型的日志

type LogConfig

type LogConfig struct {
	Debug       bool   // 是否为debug模式
	LogFilePath string // 日志路径
}

日志配置

Directories

Path Synopsis
examples
z01_hello command
z02_json_info command

Jump to

Keyboard shortcuts

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