common

package
v0.0.0-...-2a177de Latest Latest
Warning

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

Go to latest
Published: May 21, 2021 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SWITCH_ON  = 1
	SWITCH_OFF = 2
)
View Source
const (
	OK          = 0
	ERR_UNKNOWN = 10000
	ERR_NO_USER = 10001
	ERR_LIMIT   = 10002
)
View Source
const (
	ErrUnknown = "未知错误"
	ErrNoUser  = "用户信息不存在"
	ErrLimit   = "限速"
)

Variables

This section is empty.

Functions

func Debugf

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

Debugf prints formatted debug log.

func Debugln

func Debugln(v ...interface{})

Debugln prints debug log.

func Errorf

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

Errorf prints formatted error log.

func Errorln

func Errorln(v ...interface{})

Errorln prints error log.

func Fatalf

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

Fatalf prints formatted fatal log and exits.

func Fatalln

func Fatalln(v ...interface{})

Fatalln prints fatal log and exits.

func GetExternal

func GetExternal() string

func GetIntranetIp

func GetIntranetIp()

func IPString2Long

func IPString2Long(ip string) uint

func InetAton

func InetAton(ipnr net.IP) int64

func InetNtoa

func InetNtoa(ipnr int64) net.IP

func Infof

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

Infof prints formatted info log.

func Infoln

func Infoln(v ...interface{})

Infoln prints info log.

func IpIsInlist

func IpIsInlist(ip string, list []string) (isIn bool)

func LevelSet

func LevelSet(level int)

func LogFilePath

func LogFilePath(p string) func(Logger) Logger

LogFilePath returns a function to set the log file path.

func NewConf

func NewConf(filename string) error

New creates a new Config object.

func NewErrorInfo

func NewErrorInfo(code int, info string) []byte

func Warnf

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

Warnf prints formatted warn log.

func Warnln

func Warnln(v ...interface{})

Warnln prints warn log.

Types

type CodeInfo

type CodeInfo struct {
	Code int    `json:"code"`
	Info string `json:"info"`
}

type Config

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

Config represents a configuration file.

var Conf *Config

func InstanceGet

func InstanceGet() *Config

func (*Config) Bool

func (c *Config) Bool(key string) (bool, error)

func (*Config) Float64

func (c *Config) Float64(key string) (float64, error)

Float64 returns float64 type value.

func (*Config) GetArray

func (c *Config) GetArray(key string, v interface{}) (err error)

func (*Config) GetStruct

func (c *Config) GetStruct(key string, v interface{}) (err error)

func (*Config) Int

func (c *Config) Int(key string) (int, error)

Int returns int type value.

func (*Config) Int64

func (c *Config) Int64(key string) (int64, error)

Int64 returns int64 type value.

func (*Config) LastUpdateTimeGet

func (config *Config) LastUpdateTimeGet() int64

func (*Config) Reload

func (config *Config) Reload() error

Reload clears the config cache.

func (*Config) String

func (c *Config) String(key string) (string, error)

func (*Config) Watch

func (config *Config) Watch()

type LogLevel

type LogLevel int

LogLevel is the log level type.

const (
	// DEBUG represents debug log level.
	INFO LogLevel = iota
	// INFO represents info log level.
	DEBUG
	// WARN represents warn log level.
	WARN
	// ERROR represents error log level.
	ERROR
	// FATAL represents fatal log level.
	FATAL
)

type Logger

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

Logger is the logger type.

func AlsoStdout

func AlsoStdout(l Logger) Logger

AlsoStdout sets log also output to stdio.

func DebugLevel

func DebugLevel(l Logger) Logger

DebugLevel sets log level to debug.

func ErrorLevel

func ErrorLevel(l Logger) Logger

ErrorLevel sets log level to error.

func EveryDay

func EveryDay(l Logger) Logger

func EveryHour

func EveryHour(l Logger) Logger

EveryHour sets new log file created every hour.

func EveryMinute

func EveryMinute(l Logger) Logger

EveryMinute sets new log file created every minute.

func EveryMonth

func EveryMonth(l Logger) Logger

func EveryWeek

func EveryWeek(l Logger) Logger

func FatalLevel

func FatalLevel(l Logger) Logger

FatalLevel sets log level to fatal.

func InfoLevel

func InfoLevel(l Logger) Logger

InfoLevel sets log level to info.

func PrintStack

func PrintStack(l Logger) Logger

PrintStack sets log output the stack trace info.

func Start

func Start(decorators ...func(Logger) Logger) Logger

Start returns a decorated innerLogger.

func WarnLevel

func WarnLevel(l Logger) Logger

WarnLevel sets log level to warn.

func (Logger) Stop

func (l Logger) Stop()

Stop stops the logger.

type SimpleClock

type SimpleClock struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewSimpleClock

func NewSimpleClock(interval time.Duration, buckets int) *SimpleClock

func (*SimpleClock) After

func (sc *SimpleClock) After(timeout time.Duration) <-chan bool

func (*SimpleClock) Stop

func (sc *SimpleClock) Stop()

Jump to

Keyboard shortcuts

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