Documentation ¶
Index ¶
- Constants
- Variables
- func WaitForChanClose(ctx context.Context, c chan interface{})
- type ActionEntry
- type JSONWriter
- type Log
- func (log *Log) AddLoggers(loggers ...*Logger)
- func (log *Log) Close() error
- func (log *Log) CloseWithTimeout(timeout time.Duration) error
- func (log *Log) NewLogEntry() *LogEntry
- func (log *Log) SetDebug()
- func (log *Log) SetMetrics()
- func (log *Log) SetTraffic()
- func (log *Log) StartLogger(ctx context.Context)
- func (log *Log) Write(msg *LogChanMsg)
- type LogChanMsg
- type LogEntry
- func (entry *LogEntry) AddInterceptor(level LogLevel, f func(entry *LogEntry) bool)
- func (entry *LogEntry) Log(level LogLevel, args ...interface{})
- func (entry *LogEntry) LogDebug(msg string)
- func (entry *LogEntry) LogDebugf(format string, args ...interface{})
- func (entry *LogEntry) LogDetail(level LogLevel, msg, detail string)
- func (entry *LogEntry) LogError(err error)
- func (entry *LogEntry) LogErrorReport(reportType string, errors, warnings uint64)
- func (entry *LogEntry) LogErrorWithMsg(msg string, err error)
- func (entry *LogEntry) LogInfo(infoType, msg string)
- func (entry *LogEntry) LogResult(success bool, warnings, errors, sent, received, requests uint64, ...)
- func (entry *LogEntry) LogTrafficMetric(responseTime int64, sent, received uint64, requestID int, ...)
- func (entry *LogEntry) Logf(level LogLevel, format string, args ...interface{})
- func (entry *LogEntry) SetActionEntry(a *ActionEntry)
- func (entry *LogEntry) SetSessionEntry(s *SessionEntry)
- func (entry *LogEntry) ShallowCopy() *LogEntry
- func (entry *LogEntry) ShouldLogDebug() bool
- func (entry *LogEntry) ShouldLogTraffic() bool
- func (entry *LogEntry) ShouldLogTrafficMetrics() bool
- type LogLevel
- type LogSettings
- type Logger
- func CreateDummyLogger() *Logger
- func CreateJSONLogger(writer io.Writer, closeFunc func() error) *Logger
- func CreateStdoutJSONLogger() *Logger
- func CreateStdoutLogger() *Logger
- func CreateTSVLogger(header []string, writer io.Writer, closeFunc func() error) (*Logger, error)
- func NewLogger(w MsgWriter) *Logger
- type MsgWriter
- type SessionEntry
- type TSVWriter
- type Writer
Constants ¶
const ( // FieldAuthUser - User FieldAuthUser = "User" // FieldThread - Thread number FieldThread = "Thread" // FieldSession - session number FieldSession = "Session" // FieldSessionName - session name FieldSessionName = "SessionName" // FieldAppName - app name FieldAppName = "AppName" // FieldAppGUID - app GUID FieldAppGUID = "AppGUID" // FieldTick - high def time FieldTick = "Tick" // FieldAction - action name FieldAction = "Action" // FieldResponseTime - response time FieldResponseTime = "ResponseTime" // FieldSuccess - action success FieldSuccess = "Success" // FieldWarnings - warning count FieldWarnings = "Warnings" // FieldErrors - error count FieldErrors = "Errors" // FieldStack - stack trace FieldStack = "Stack" // FieldSent - bytes sent FieldSent = "Sent" // FieldReceived - bytes received FieldReceived = "Received" // FieldLabel - action label FieldLabel = "Label" // FieldActionID - action id number FieldActionID = "ActionId" // FieldObjectType - object type FieldObjectType = "ObjectType" // FieldDetails - details string FieldDetails = "Details" // FieldInfoType - type of info logging FieldInfoType = "InfoType" // FieldRequestsSent - request counter FieldRequestsSent = "RequestsSent" // FieldTime - logging time FieldTime = "time" // FieldTimestamp - to be used for time without timezone for G3 compliance FieldTimestamp = "timestamp" // FieldLevel - logging level FieldLevel = "level" // FieldMessage - message FieldMessage = "message" )
Variables ¶
var ( //AllFields for logging (i.e. use as headers) AllFields = []string{FieldTime, FieldAction, FieldLabel, FieldActionID, FieldLevel, FieldInfoType, FieldMessage, FieldDetails, FieldSuccess, FieldResponseTime, FieldAppName, FieldAppGUID, FieldAuthUser, FieldThread, FieldSession, FieldSessionName, FieldTick, FieldObjectType, FieldWarnings, FieldErrors, FieldStack, FieldSent, FieldReceived, FieldRequestsSent, FieldTimestamp} )
Functions ¶
func WaitForChanClose ¶
WaitForChanClose which ever comes first context cancel or c closed. Returns instantly if channel is nil.
Types ¶
type ActionEntry ¶
ActionEntry log fields living during action
type JSONWriter ¶
type JSONWriter struct {
// contains filtered or unexported fields
}
JSONWriter wrapper implementing MessageWriter for zerolog
func NewJSONWriter ¶
func NewJSONWriter(zlgr *zerolog.Logger) *JSONWriter
NewJSONWriter wrapper implementing MessageWriter for zerolog
func (*JSONWriter) Level ¶
func (jw *JSONWriter) Level(lvl LogLevel)
Level implement MsgWriter interface
func (*JSONWriter) WriteMessage ¶
func (jw *JSONWriter) WriteMessage(msg *LogChanMsg) error
WriteMessage implement MsgWriter interface
type Log ¶
type Log struct { Closed chan interface{} Settings LogSettings // contains filtered or unexported fields }
Log main struct to keep track of and propagate log entries to loggers. Close finished will be signaled on Closed channel.
func (*Log) AddLoggers ¶
AddLoggers to be used for logging
func (*Log) CloseWithTimeout ¶
CloseWithTimeout functions with custom timeout
func (*Log) NewLogEntry ¶
NewLogEntry create new LogEntry using current logger
func (*Log) StartLogger ¶
StartLogger start async reading on log channel
func (*Log) Write ¶
func (log *Log) Write(msg *LogChanMsg)
Write log message, should be done in go routine to not block
type LogChanMsg ¶
type LogChanMsg struct { SessionEntry ActionEntry // contains filtered or unexported fields }
LogChanMsg container for row to be logged
func NewEmptyLogChanMsg ¶
func NewEmptyLogChanMsg() *LogChanMsg
NewLogChanMsg create new LogChanMsg, to be used for testing purposes
type LogEntry ¶
type LogEntry struct { Session *SessionEntry Action *ActionEntry // contains filtered or unexported fields }
LogEntry entry used for logging
func (*LogEntry) AddInterceptor ¶
AddInterceptor to log entry, return false to avoid logging
func (*LogEntry) LogErrorReport ¶
LogErrorReport log warning and error count
func (*LogEntry) LogErrorWithMsg ¶
LogErrorWithMsg log error entry with message
func (*LogEntry) LogResult ¶
func (entry *LogEntry) LogResult(success bool, warnings, errors, sent, received, requests uint64, responsetime int64, details string)
LogResult log result entry
func (*LogEntry) LogTrafficMetric ¶
func (entry *LogEntry) LogTrafficMetric(responseTime int64, sent, received uint64, requestID int, method, params, trafficType string)
LogTrafficMetric log traffic metric entry
func (*LogEntry) SetActionEntry ¶
func (entry *LogEntry) SetActionEntry(a *ActionEntry)
SetActionEntry set new session entry
func (*LogEntry) SetSessionEntry ¶
func (entry *LogEntry) SetSessionEntry(s *SessionEntry)
SetSessionEntry set new session entry
func (*LogEntry) ShallowCopy ¶
ShallowCopy log entry, creates new log entry with pointers to exact same data, but with a new mutex
func (*LogEntry) ShouldLogDebug ¶
ShouldLogDebug should debug info be logged
func (*LogEntry) ShouldLogTraffic ¶
ShouldLogTraffic should traffic be logged
func (*LogEntry) ShouldLogTrafficMetrics ¶
ShouldLogTrafficMetrics should traffic metrics be logged
type LogLevel ¶
type LogLevel int
LogLevel of logging
type LogSettings ¶
LogSettings settings
type Logger ¶
type Logger struct { Writer MsgWriter // contains filtered or unexported fields }
Logger container for writer and close functions
func CreateDummyLogger ¶
func CreateDummyLogger() *Logger
CreateDummyLogger auto discarding all entries
func CreateJSONLogger ¶
CreateJSONLogger with io.Writer
func CreateStdoutJSONLogger ¶
func CreateStdoutJSONLogger() *Logger
CreateStdoutJSONLogger create logger for JSON on terminal for later adding to loggers list
func CreateStdoutLogger ¶
func CreateStdoutLogger() *Logger
CreateStdoutLogger create logger for JSON on terminal for later adding to loggers list
func CreateTSVLogger ¶
CreateTSVLogger with io.Writer
func (*Logger) AddCloseFunc ¶
AddCloseFunc add sub logger close function to be called upon logger close
type MsgWriter ¶
type MsgWriter interface { // WriteMessage to log WriteMessage(msg *LogChanMsg) error // Set log level Level(lvl LogLevel) }
MsgWriter implement to write log entry
type SessionEntry ¶
type SessionEntry struct { User string Thread uint64 Session uint64 SessionName string AppName string AppGUID string }
SessionEntry log fields living of entire session
type TSVWriter ¶
TSVWriter write log rows in tab separated format
func NewTSVWriter ¶
NewTSVWriter instance
func (*TSVWriter) WriteMessage ¶
func (writer *TSVWriter) WriteMessage(msg *LogChanMsg) error
WriteMessage implement MsgWriter interface