log

package
v0.0.0-...-3fbbd91 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEBUG Level = iota + 1
	INFO
	WARN
	ERROR
	FATAL

	Debug = "Debug"
	Info  = "Info"
	Warn  = "Warn"
	Error = "Error"
	Fatal = "Fatal"

	SHORT = iota
	FULL

	FilePathShort = "Short"
	FilePathFull  = "Full"
)
View Source
const (
	DependancyTypeHTTP  = "http"
	DependancyTypeDB    = "db"
	DependancyTypeRedis = "redis"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// The supported log levels are as follows
	// DEBUG < INFO < WARN < ERROR < FATAL
	// If a log level is specified all logs with level below the specified level are ignored
	// Eg. If INFO is selected, All DEBUG logs are ignored
	// If ERROR is selected all logs except ERROR and FATAL are ignored
	Level Level

	// Log levels in string format.
	// The supported log level strings are Debug, Info, Warn, Error, Fatal
	// You can specify log level using Level Enum or string
	// The Enum value is given first preference
	LevelStr string

	// Size of the file to be printed, there are two possible values FULL, SHORT
	// SHORT - Only the file name is displayed
	// FULL - File name along with full file path is specified
	// SHORT is used by default
	FilePathSize int

	// Log Reference (context) ID to be added to each log
	// This can be used to search relevent logs for the context
	Reference string

	AppName string

	RemoteLoggerURL string

	RemoteToken string

	RemoteUserName string
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(name string) *Config

func (*Config) SetFilePathSize

func (c *Config) SetFilePathSize(filePathSize int)

func (*Config) SetFilePathSizeStr

func (c *Config) SetFilePathSizeStr(fps string)

func (*Config) SetLevel

func (c *Config) SetLevel(level Level)

func (*Config) SetLevelStr

func (c *Config) SetLevelStr(lvl string)

func (*Config) SetReference

func (c *Config) SetReference(ref string)

func (*Config) SetRemoteConfig

func (c *Config) SetRemoteConfig(url, token, uname string)

type Level

type Level int

type Log

type Log struct {
	Level          string    `json:"level"`
	Timestamp      time.Time `json:"timestamp"`
	Title          string    `json:"message"`
	Message        string    `json:"full_message"`
	AppName        string    `json:"app_name"`
	RefID          string    `json:"ref_id"`
	File           string    `json:"file"`
	Line           string    `json:"line"`
	ResponseTime   float64   `json:"response_time"`
	StatusCode     int       `json:"status_code"`
	Method         string    `json:"method"`
	Request        string    `json:"request"`
	UserAgent      string    `json:"user_agent"`
	CustomerID     string    `json:"customer_id"`
	IPAddress      string    `json:"ip_address"`
	RequestGroup   string    `json:"request_group" example:"Ping"`
	AppVersion     string    `json:"app_version" example:"App Version"`
	TimeTaken      float64   `json:"time_taken" example:"1.11"`
	DependancyType string    `json:"dependancy_type" example:"http,database"`
	DependancyName string    `json:"dependancy_name" example:"googleapi,booktripsp"`
}

type Logger

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

func New

func New(config *Config) *Logger

func (*Logger) Debug

func (l *Logger) Debug(v ...interface{})

func (*Logger) Debugf

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

func (*Logger) Error

func (l *Logger) Error(v ...interface{})

func (*Logger) Errorf

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

func (*Logger) Fatal

func (l *Logger) Fatal(v ...interface{})

func (*Logger) Fatalf

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

func (*Logger) GetFileLine

func (l *Logger) GetFileLine(n int) (string, int)

func (*Logger) GetRef

func (l *Logger) GetRef() string

func (*Logger) Info

func (l *Logger) Info(v ...interface{})

func (*Logger) Infof

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

func (*Logger) Init

func (l *Logger) Init() error

func (*Logger) Log

func (l *Logger) Log(lg *Log)

func (*Logger) LogAPIInfo

func (l *Logger) LogAPIInfo(r *http.Request, responseTime float64, status int)

func (*Logger) PostToRemote

func (l *Logger) PostToRemote(level, msg string)

func (*Logger) Warn

func (l *Logger) Warn(v ...interface{})

func (*Logger) Warnf

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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