log

package module
v0.0.0-...-14f1ab6 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2022 License: Apache-2.0 Imports: 21 Imported by: 1

README

Log

该模块在Logrus基础上进行二次封装,支持打印行号,支持格式化日志,支持本地生成日志文件和以JSON格式远程上报日志。

环境配置

  • 本项目编译之前,需用户自行安装Golangglide工具;
  • 在编译时,本项目会先从github上拉去以来的项目,编译时间视具体网络环境而定;
  • 要求linuxmacos系统即可。

编译

  • 第一次下载程序后,先make update,下载第三方依赖库文件;
  • 最后再make, 编译程序(如果第三方库安装vendor目录存在,则可直接make,无需操作install和update);

引用

  • import "github.com/dongjialong2006/log"

示例

{ package main

import "github.com/dongjialong2006/log"

func main() {
	logger := log.New("main")
	logger.Debug("test")
}

}

time="2018-07-25 15:37:05.2244" level=debug msg=test file="/Users/dongchaofeng/go/src/log/log_test.go" line=19 model=test

Documentation

Index

Constants

View Source
const (
	LOCAL  = "local"
	REMOTE = "remote"
)
View Source
const (
	DEFAULT_ROTATION_COUNT        = 6
	DEFAULT_WATCHER_FILES_BY_NUM  = 6
	DEFAULT_WATCHER_FILES_BY_SIZE = 10 * 1024 * 1024
)
View Source
const (
	DEFAULT_LOG_NAME  = "./log/default.log"
	DEFAULT_LOG_LEVEL = "debug"
)
View Source
const (
	LOG_DEBUG_LEVEL = "debug"
	LOG_INFO_LEVEL  = "info"
	LOG_ERROR_LEVEL = "error"
	LOG_FATAL_LEVEL = "fatal"
	LOG_WARN_LEVEL  = "warn"
	LOG_PANIC_LEVEL = "panic"
)
View Source
const (
	TCP   = "tcp"
	UDP   = "udp"
	HTTP  = "http"
	HTTPS = "https"
)
View Source
const (
	DEFAULT_ROTATION_TIME = 24 * time.Hour
)

Variables

This section is empty.

Functions

func WithCaller

func WithCaller() option

func WithContext

func WithContext(ctx context.Context) option

func WithFields

func WithFields(fields map[string]interface{}) option

func WithFluent

func WithFluent(value bool) option

func WithLogLevel

func WithLogLevel(level string) option

func WithLogName

func WithLogName(name string) option

func WithMaxAge

func WithMaxAge(interval time.Duration) option

func WithRemoteAddr

func WithRemoteAddr(addr string) option

func WithRemoteProtocolType

func WithRemoteProtocolType(protocol string) option

func WithRotationCount

func WithRotationCount(num int) option

func WithRotationTime

func WithRotationTime(interval time.Duration) option

func WithTerminal

func WithTerminal(out bool) option

func WithWatchEnable

func WithWatchEnable(enable bool) option

func WithWatchLogsByNum

func WithWatchLogsByNum(num int) option

func WithWatchLogsBySize

func WithWatchLogsBySize(size int64) option

Types

type Entry

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

func New

func New(name string, opts ...option) *Entry

func (Entry) Debug

func (e Entry) Debug(args ...interface{})

func (Entry) Debugf

func (e Entry) Debugf(format string, args ...interface{})

func (Entry) Error

func (e Entry) Error(args ...interface{})

func (Entry) Errorf

func (e Entry) Errorf(format string, args ...interface{})

func (Entry) Fatal

func (e Entry) Fatal(args ...interface{})

func (Entry) Fatalf

func (e Entry) Fatalf(format string, args ...interface{})

func (Entry) Info

func (e Entry) Info(args ...interface{})

func (Entry) Infof

func (e Entry) Infof(format string, args ...interface{})

func (Entry) Panic

func (e Entry) Panic(args ...interface{})

func (Entry) Panicf

func (e Entry) Panicf(format string, args ...interface{})

func (Entry) Warn

func (e Entry) Warn(args ...interface{})

func (Entry) Warnf

func (e Entry) Warnf(format string, args ...interface{})

func (Entry) WithError

func (e Entry) WithError(err error) *Entry

func (Entry) WithField

func (e Entry) WithField(key string, value interface{}) *Entry

func (Entry) WithFields

func (e Entry) WithFields(fields Fields) *Entry

type Fields

type Fields map[string]interface{}

type Log

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

func NewLog

func NewLog(name string, opts ...option) (*Log, error)

func (*Log) NewEntry

func (l *Log) NewEntry(name string) *Entry

func (*Log) Stop

func (l *Log) Stop()

Jump to

Keyboard shortcuts

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