utils

package
v0.0.0-...-dddcec1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package utils @Description:

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLogLevel

func GetLogLevel(level string) []log.Level

GetLogLevel 获取日志等级

可能的值有

"trace","debug","info","warn","warn","error"

func PathExists

func PathExists(path string) (bool, error)

PathExists *

  • @Description: 判断文件或文件夹是否存在 如果返回的错误为nil,说明文件或文件夹存在 如果返回的错误类型使用os.IsNotExist()判断为true,说明文件或文件夹不存在 如果返回的错误为其它类型,则不确定是否在存在
  • @param path
  • @return bool
  • @return error
  • example

func WriteToFile

func WriteToFile(name string, data []byte) error

Types

type LogFormat

type LogFormat struct {
	TimeStampFormat string `json:"time_stamp_format"`

	LogContent string `json:"log_content"`

	LogTruncate bool `json:"log_truncate"`
}

func (*LogFormat) Format

func (f *LogFormat) Format(entry *log.Entry) ([]byte, error)

Format *

  • @Description:
  • @receiver f
  • @param entry
  • @return []byte
  • @return error
  • example

type LogHook

type LogHook struct {
	EnableLogChan bool

	LogChan chan string
	// contains filtered or unexported fields
}

LogHook @Description:

func NewLogHook

func NewLogHook(formatter log.Formatter, levels []log.Level, writers ...io.Writer) *LogHook

NewLogHook *

  • @Description:
  • @param formatter
  • @param levels
  • @param writers
  • @return *LogHook
  • example

func (*LogHook) AddWriter

func (l *LogHook) AddWriter(writer ...io.Writer)

AddWriter *

  • @Description:
  • @receiver l
  • @param writer
  • example

func (*LogHook) Fire

func (l *LogHook) Fire(entry *log.Entry) error

Fire *

  • @Description:
  • @receiver l
  • @param entry
  • @return error
  • example

func (*LogHook) Levels

func (l *LogHook) Levels() []log.Level

Levels *

  • @Description:
  • @receiver l
  • @return []log.Level
  • example

func (*LogHook) SetFormat

func (l *LogHook) SetFormat(format log.Formatter)

SetFormat *

  • @Description:
  • @receiver l
  • @param format
  • example

Jump to

Keyboard shortcuts

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