logutil

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2019 License: MIT Imports: 4 Imported by: 3

Documentation

Overview

Package logutil implements util functions for logging. Using this package you can get formatted string with current time, function and line number of call place with specified depth and shortcut to call place with specified depth. Also this package contains constants with levels of logging and entity for log records.

Index

Constants

View Source
const (
	// INFO const string for info logging level.
	INFO = "INFO"

	// WARNING const string for warning logging level.
	WARNING = "WARNING"

	// TRACE const string for trace logging level.
	TRACE = "TRACE"

	// ERROR const string for error logging level.
	ERROR = "ERROR"
)
View Source
const DefaultLogDepth int = 4

DefaultLogDepth default depth for runtime.Caller which goes through log factory and print functions.

Variables

This section is empty.

Functions

func GetCallPlace

func GetCallPlace(depth int) string

GetCallPlace returns shortcut to file and code line number using GetFnAndLineNumber. Int param "depth" defines depth for GetFnAndLineNumber.

func GetCurrentTime

func GetCurrentTime() string

GetCurrentTime returns string representation of current time.

func SetProjectName added in v0.2.1

func SetProjectName(projName string)

SetProjectName sets name of project to get call place without environment dirs.

Types

type LogRecord

type LogRecord struct {
	// LogLevel is a field for log level.
	LogLevel string `json:"level"`

	// LogTime is a field for log time.
	LogTime string `json:"time"`

	// CallPlace is a field for call place.
	CallPlace string `json:"call_place"`

	// Msg is a field for log message.
	Msg string `json:"message"`
}

LogRecord is entity for logging. JSON tags allows to make logs in JSON format.

func (*LogRecord) SetLevel

func (lr *LogRecord) SetLevel(level string)

SetLevel sets level of log for record.

Jump to

Keyboard shortcuts

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