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 ¶
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" )
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 ¶
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.