logs

package module
v0.0.0-...-566d3c7 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2023 License: MIT Imports: 10 Imported by: 3

README

logs

The logs system.

Documentation

Overview

Author: Kernel.Huang Mail: kernelman79@gmail.com Date: 3/18/21 1:01 PM Package: log

Author: Kernel.Huang Mail: kernelman79@gmail.com Date: 3/18/21 1:01 PM

Author: Kernel.Huang Mail: kernelman79@gmail.com File: config.go Date: 8/9/22 1:57 PM

Index

Constants

View Source
const DateFormat = "2006-01-02"
View Source
const TimeFormat = "2006-01-02 15:04:05"

Variables

View Source
var Toml = new(TomlConfig)

Functions

func BootLogger

func BootLogger() (err error)

初始化日志配置

func CloseLogger

func CloseLogger()

关闭日志

func CurrentAndAbsPath

func CurrentAndAbsPath() string

当前执行程序的绝对路径

func Debug

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

输出调试日志

func Error

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

输出错误日志

func Fatal

func Fatal(v ...interface{})

输出致命错误日志, 并退出系统

func Fatally

func Fatally(v ...interface{})

输出致命错误日志, 并退出系统

func GetAbsPath

func GetAbsPath(current string) string

获取当前执行程序的绝对路径

func GetConfigDir

func GetConfigDir() string

获取配置目录名

func GetConfigPath

func GetConfigPath() string

获取日志配置名

func GetCurrentDir

func GetCurrentDir() string

获取当前执行程序的绝对目录路径

func GetCustomConfigDir

func GetCustomConfigDir(dirname string) string

Get config dir of custom

func GetCustomConfigPath

func GetCustomConfigPath(dirname string, filename string) string

Get config path

func GetLastPath

func GetLastPath(currentPath string) string

获取路径的上个目录

func GetLogsDir

func GetLogsDir() string

获取日志目录

func GetLogsFilename

func GetLogsFilename() string

获取日志文件名

func GetLogsLevel

func GetLogsLevel() string

获取日志级别, 值为OFF则关闭日志

func GetLogsPrefix

func GetLogsPrefix() string

获取日志文件内容前缀

func GetRootPath

func GetRootPath() string

获取项目根目录

func Info

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

输出信息日志

func Print

func Print(v ...interface{})

输出格式化日志

func Printf

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

输出格式化日志

func Println

func Println(v ...interface{})

输出格式化日志

func SetCurrentPath

func SetCurrentPath() string

设置当前执行程序的绝对路径

func Trace

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

输出跟踪日志

func Warning

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

输出警告日志

Types

type LEVEL

type LEVEL byte
const (
	TRACE LEVEL = iota
	DEBUG
	INFO
	WARN
	ERROR
	OFF
)

type LoggerConf

type LoggerConf struct {
	FileDir  string
	FileName string
	Prefix   string
	Level    string
}

type TomlConfig

type TomlConfig struct {
	Structured interface{}
	// contains filtered or unexported fields
}

func GetToml

func GetToml() *TomlConfig

获取Toml配置解析服务

func (*TomlConfig) AtBool

func (tf *TomlConfig) AtBool() bool

Example: result := Tome.NewToml(dirname, filename).Zone("zoneName").Get("key").AtBool()

func (*TomlConfig) AtInt

func (tf *TomlConfig) AtInt() int

Example: result := Tome.NewToml(dirname, filename).Zone("zoneName").Get("key").AtInt()

func (*TomlConfig) AtStr

func (tf *TomlConfig) AtStr() string

Example: result := Tome.NewToml(dirname, filename).Zone("zoneName").Get("key").AtStr()

func (*TomlConfig) Fetch

func (tf *TomlConfig) Fetch(key string) *TomlConfig

Example: result := Tome.NewToml(dirname, filename).Zone("zoneName").Fetch("key").ToStr()

func (*TomlConfig) Get

func (tf *TomlConfig) Get(key string) *TomlConfig

Example: result := Tome.NewToml(dirname, filename).Zone("zoneName").Get("key").To()

func (*TomlConfig) NewToml

func (tf *TomlConfig) NewToml(dirname string, filename string) *TomlConfig

func (*TomlConfig) Read

func (tf *TomlConfig) Read(key string) *TomlConfig

Example: result := Tome.NewToml(dirname, filename).Read("zoneName.key").ToStr() or ToInt()

func (*TomlConfig) To

func (tf *TomlConfig) To() interface{}

*

  • Example: result := Tome.NewToml(dirname, filename).Zone("zoneName").Get("key").To()

func (*TomlConfig) ToBool

func (tf *TomlConfig) ToBool() bool

Example: result := Tome.NewToml(dirname, filename).Read("zoneName.key").ToBool()

func (*TomlConfig) ToInt

func (tf *TomlConfig) ToInt() int

Example: result := Tome.NewToml(dirname, filename).Read("zoneName.key").ToInt()

func (*TomlConfig) ToStr

func (tf *TomlConfig) ToStr() string

Example: result := Tome.NewToml(dirname, filename).Read("zoneName.key").ToStr()

func (*TomlConfig) Zone

func (tf *TomlConfig) Zone(key string) *TomlConfig

Example: result := Tome.NewToml(dirname, filename).Zone("zoneName").Get("key").To()

Jump to

Keyboard shortcuts

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