golog

package module
v0.0.0-...-1be06af Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: GPL-3.0 Imports: 5 Imported by: 0

README

golog

Golang实现的简易日志库

使用方法

import "github.com/Hui4401/golog"

// 输出到文件,可选同时输出到终端
fileLogger := golog.NewFileLogger(golog.LevelDebug, "logs/golog.log", true)
fileLogger.Debug("this is a debug log")
fileLogger.Info("this is a info log")
fileLogger.Error("this is a error log")
fileLogger.Close()

// 仅输出到终端
consoleLogger := golog.NewConsoleLogger(golog.LevelDebug)
consoleLogger.Debug("this is a debug log")
consoleLogger.Info("this is a info log")
consoleLogger.Error("this is a error log")
consoleLogger.Close()

Documentation

Index

Constants

View Source
const (
	LevelDebug levelType = 1
	LevelInfo  levelType = 2
	LevelError levelType = 3
)

Variables

This section is empty.

Functions

This section is empty.

Types

type LogInterface

type LogInterface interface {
	SetLevel(level levelType)
	Debug(format string, args ...interface{})
	Info(format string, args ...interface{})
	Error(format string, args ...interface{})
	Close()
}

func NewConsoleLogger

func NewConsoleLogger(level levelType) LogInterface

func NewFileLogger

func NewFileLogger(level levelType, filePath string, toConsole bool) LogInterface

Jump to

Keyboard shortcuts

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