glog

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2023 License: MIT Imports: 13 Imported by: 9

README

glog

Log package for Golang.

Documentation

Index

Constants

View Source
const (
	SecondToNano int64 = 1e9
	HourToSecond int64 = 3600
	HourToNano   int64 = HourToSecond * SecondToNano
	DayToSecond  int64 = 24 * HourToSecond
	DayToNano    int64 = 24 * HourToNano
)

==================================================================================================== 時間轉換 ====================================================================================================

View Source
const (
	KB int64 = 1024
	MB int64 = 1024 * KB
	GB int64 = 1024 * MB
	TB int64 = 1024 * GB
	PB int64 = 1024 * TB
	EB int64 = 1024 * PB
)

==================================================================================================== 檔案大小轉換(單位:Byte) ====================================================================================================

View Source
const DISPLAYTIME string = "2006/01/02 15:04:05"

時間輸出格式

View Source
const FILEINFO int = 0b0100
View Source
const FILENAMETIME string = "2006-01-02-15-04"

檔名時間格式,間隔時間類型為 Second 的設置只在開發期間使用,因此檔名時間格式精細度到分鐘即可

View Source
const LINEINFO int = 0b1000
View Source
const TOCONSOLE int = 0b0001

是否輸出到 Console 或 輸出成檔案,由低位到高位,以二進制分別表示 1. 是否輸出到 Console 2. 是否輸出成檔案 3. 是否輸出檔案資訊 3. 是否輸出行數資訊

View Source
const TOFILE int = 0b0010

Variables

This section is empty.

Functions

func BasicOption

func BasicOption(level LogLevel, toConsole bool, toFile bool, fileInfo bool) *basicOption

func DefaultOption added in v1.0.1

func DefaultOption(debugToFile bool, infoToFile bool) *defaultOption

func Flush

func Flush()

func FolderOption added in v1.1.0

func FolderOption(folder string) *folderOption

func UtcOption added in v1.0.1

func UtcOption(utc float32) *utcOption

Types

type LogLevel

type LogLevel int

==================================================================================================== LogLevel ====================================================================================================

const (
	DebugLevel LogLevel = iota
	InfoLevel
	WarnLevel
	ErrorLevel
)

func (LogLevel) String

func (l LogLevel) String() string

type Logger

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

func GetLogger

func GetLogger(folder string, loggerName string, level LogLevel, callByStruct bool, options ...Option) *Logger

func (*Logger) CheckCaller added in v1.1.0

func (l *Logger) CheckCaller(skip int) uintptr

可使用 runtime.FuncForPC(ptr) 獲得進一步的資訊

func (*Logger) CheckCallers added in v1.1.0

func (l *Logger) CheckCallers()

func (*Logger) Debug

func (l *Logger) Debug(message string, a ...any)

func (*Logger) Error

func (l *Logger) Error(message string, a ...any)

func (*Logger) Flush

func (l *Logger) Flush()

func (*Logger) Info

func (l *Logger) Info(message string, a ...any)

func (*Logger) Logout

func (l *Logger) Logout(level LogLevel, message string) error

func (*Logger) SetBufferSize

func (l *Logger) SetBufferSize(size uint16)

func (*Logger) SetLogLevel

func (l *Logger) SetLogLevel(level LogLevel)

設置 Log 輸出等級

func (*Logger) SetOptions added in v1.0.1

func (l *Logger) SetOptions(options ...Option)

可在建構子之外,設置 Logger 各項參數

func (*Logger) SetShiftCondition added in v1.1.0

func (l *Logger) SetShiftCondition(shiftType ShiftType, times int64, size int64)

func (*Logger) SetSizeLimit

func (l *Logger) SetSizeLimit(size int64)

設置每個 Log 檔的大小,超過後更新輸出位置

func (*Logger) Warn

func (l *Logger) Warn(message string, a ...any)

type Option

type Option interface {
	SetOption(*Logger)
}

type ShiftType added in v1.1.0

type ShiftType byte

==================================================================================================== ShiftType ====================================================================================================

const (
	ShiftNone ShiftType = iota
	ShiftSecond
	ShiftHour
	ShiftDay
	ShiftSize
	ShiftSecondAndSize
	ShiftHourAndSize
	ShiftDayAndSize
)

func (ShiftType) String added in v1.1.1

func (st ShiftType) String() string

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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