goLogger

package module
v0.0.0-...-600962c Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2021 License: GPL-2.0 Imports: 9 Imported by: 0

README

goLogger

介绍

go logger project

软件架构

软件架构说明

  • 参数介绍:

  • -d 只下载不安装

  • -f 只有在你包含了 -u 参数的时候才有效,不让 -u 去验证 import 中的每一个都已经获取了,这对于本地 fork 的包特别有用

  • -fix 在获取源码之后先运行 fix,然后再去做其他的事情

  • -t 同时也下载需要为运行测试所需要的包

  • -u 强制使用网络去更新包和它的依赖包

  • -v 显示执行的命令

  • go get -u gitee.com/ixigua0526/goLogger

  • go run demo.go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetInfo

func GetInfo(skip int) (funcName, fileName string, LineNum int)

Types

type ConsolLogger

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

日志结构体

func NewConsolLogger

func NewConsolLogger(levelStr string) (ConsolLogger, error)

Newlog构造函数

func (ConsolLogger) Debug

func (c ConsolLogger) Debug(format string, a ...interface{})

格式化字符串

func (ConsolLogger) Error

func (c ConsolLogger) Error(format string, a ...interface{})

func (ConsolLogger) Info

func (c ConsolLogger) Info(format string, a ...interface{})

func (ConsolLogger) Warn

func (c ConsolLogger) Warn(format string, a ...interface{})

type Element

type Element map[string]string

section下面的键值对

type FileLogger

type FileLogger struct {
	LogLevel       LogLevel
	LogFileName    string
	LogFilePath    string
	FileOBJ        *os.File
	ErrorFileOBJ   *os.File
	LogMaxFileSize int64
}

FileLogger日志文件结构体

func NewFileLogger

func NewFileLogger(levelStr, fileName, filePath string, maxFileSize int64) (*FileLogger, error)

FileLogger构造函数返回结构体指针*FileLogger levelStr:UNKNOWN、DEBUG、INFO、WARN、ERROR filePath:日志文件路径 maxFileSize:最大文件大小,单位字节(B)

func (*FileLogger) CheckSize

func (f *FileLogger) CheckSize(file *os.File) bool

检测文件大小

func (*FileLogger) CloseLogFile

func (f *FileLogger) CloseLogFile() error

释放文件句柄

func (*FileLogger) Debug

func (f *FileLogger) Debug(format string, a ...interface{})

格式化字符串

func (*FileLogger) Error

func (f *FileLogger) Error(format string, a ...interface{})

func (*FileLogger) Info

func (f *FileLogger) Info(format string, a ...interface{})

func (*FileLogger) Warn

func (f *FileLogger) Warn(format string, a ...interface{})

type IniFile

type IniFile struct {
	Object map[string][]Element
	// contains filtered or unexported fields
}

ini文件结构(对象) section为key

func NewIniFile

func NewIniFile() *IniFile

IniFile的构造函数

func (*IniFile) GetSection

func (i *IniFile) GetSection() []string

获取所有的Section

func (*IniFile) GetValue

func (i *IniFile) GetValue(section string) (string, []Element)

获取section下的键值对数据

func (*IniFile) GetValueInSection

func (i *IniFile) GetValueInSection(section, key string) (string, string)

获取某个section下的某个键的值

func (*IniFile) Parse

func (i *IniFile) Parse(str string)

解析一行中的内容

func (*IniFile) Readfile

func (i *IniFile) Readfile(filename string)

读取文件

type LogLevel

type LogLevel uint16
const (
	UNKNOWN LogLevel = iota
	DEBUG
	INFO
	WARN
	ERROR
)

type Logger

type Logger interface {
	Debug(format string, a ...interface{})
	Info(format string, a ...interface{})
	Warn(format string, a ...interface{})
	Error(format string, a ...interface{})
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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