g_log

package module
v0.0.0-...-0129575 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Copyright (c) 2020 Higker Open Source: MIT License Author: higker <deen.job@qq.com>

Index

Constants

View Source
const (
	// Log file size
	// You can also customize. Unit is kb.
	MB10  int64 = 10 * 1024 * 1024
	MB100 int64 = 100 * 1024 * 1024
	GB1   int64 = 10 * MB100
)
View Source
const (
	//[INFO] 2006-01-02 13:05.0006 MP - Position: test.go|main.test:21 - Message: news
	FORMAT = "[%s] - Date: %s - Position: %s - Message: %s"
)
View Source
const (
	SKIP = 3
)

Runtime caller skip

Variables

This section is empty.

Functions

func BuildCallerStr

func BuildCallerStr(skip int) string

Types

type FileLog

type FileLog struct {
	WheError  bool     // whether enable error log file.
	Directory string   // Log save directory
	FileName  string   // Log file name
	File      *os.File // Log file  pointer
	ErrFile   *os.File // Error file log pointer
}

func (*FileLog) Debug

func (f *FileLog) Debug(value string, args ...interface{})

func (*FileLog) Error

func (f *FileLog) Error(value string, args ...interface{})

func (*FileLog) Info

func (f *FileLog) Info(value string, args ...interface{})

func (*FileLog) Warning

func (f *FileLog) Warning(value string, args ...interface{})

type Level

type Level int

Custom logging level type.

const (
	DEBUG Level = iota
	INFO
	WARNING
	ERROR
)

func (Level) ToStr

func (lev Level) ToStr() string

TODO: Logging level to string

type Log

type Log Logger

type LogRecord

type LogRecord interface {
	OutPutMessage(v string)
}

Logging record

type LogTimeZone

type LogTimeZone string
const (
	//https://blog.imdst.com/guo-bf/
	//美东     EST         /usr/share/zoneinfo/EST5EDT
	//美西     PST         /usr/share/zoneinfo/PST8PDT
	//澳洲     CST         /usr/share/zoneinfo/CST6CDT
	//欧洲     GMT         /usr/share/zoneinfo/Europe/London
	//泰国     Thailand    /usr/share/zoneinfo/Asia/Bangkok
	//越南     Vietnam     /usr/share/zoneinfo/Asia/Ho_Chi_Minh
	//新加坡   Singapore   /usr/share/zoneinfo/Asia/Singapore
	//台湾     Taiwan      /usr/share/zoneinfo/Asia/Taipei
	//香港     HongKong    /usr/share/zoneinfo/Asia/Hong_Kong
	//日本     Japan       /usr/share/zoneinfo/Asia/Tokyo
	//韩国     Korea       /usr/share/zoneinfo/Asia/Pyongyang
	EST       LogTimeZone = "EST5EDT"
	PST       LogTimeZone = "PST8PDT"
	CST       LogTimeZone = "CST6CDT"
	GMT       LogTimeZone = "Europe/London"
	Thailand  LogTimeZone = "Asia/Bangkok"
	Vietnam   LogTimeZone = "Asia/Ho_Chi_Minh"
	Singapore LogTimeZone = "Asia/Singapore"
	Taiwan    LogTimeZone = "Asia/Taipei"
	HongKong  LogTimeZone = "Asia/Hong_Kong"
	Japan     LogTimeZone = "Asia/Tokyo"
	Korea     LogTimeZone = "Asia/Pyongyang"
	China                 = "Asia/Shanghai" // Shanghai China

)

type Logger

type Logger interface {
	// English: Info level log
	Info(value string, arg ...interface{})
	// Debug level log
	Debug(value string, arg ...interface{})
	// Error level log
	Error(value string, arg ...interface{})
	// Warning level log
	Warning(value string, arg ...interface{})
}

Logger interface. Abstract Logger object.

func NewClog

func NewClog(level Level, zone LogTimeZone) Logger

Build console Logger Level: logger Level Zone : logger Time Zone

type TimeZone

type TimeZone struct {
	TimeZoneStr LogTimeZone // your custom time zone,recommend use this.
}

自定义时间类型 :customize time zone type struct

func (*TimeZone) NanoSecondStr

func (tz *TimeZone) NanoSecondStr() string

ret: nanosecond string

func (*TimeZone) NowTimeStr

func (tz *TimeZone) NowTimeStr() (ts string)

get time str fmt: 2006-01-02 15:04:05.0000 PM

Jump to

Keyboard shortcuts

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