diff --git a/log/log.go b/log/log.go index 8e95bfa..8ec5205 100644 --- a/log/log.go +++ b/log/log.go @@ -10,9 +10,23 @@ const ( DirClientToServer // Client to Server communication ) +const ( + // LevelError is the Level for only ERROR log messages + LevelError Level = iota + // LevelWarn is the Level for WARN and higher log messages + LevelWarn + // LevelInfo is the Level for INFO and higher log messages + LevelInfo + // LevelDebug is the Level for DEBUG and higher log messages + LevelDebug +) + // Direction is a type wrapper for the direction a debug log message goes type Direction int +// Level is a type wrapper for an int +type Level int + // Log represents a log message type that holds a log Direction, a Format string // and a slice of Messages type Log struct { @@ -28,3 +42,12 @@ type Logger interface { Warnf(Log) Errorf(Log) } + +// directionPrefix will return a prefix string depending on the Direction. +func (l Log) directionPrefix() string { + p := "C <-- S:" + if l.Direction == DirClientToServer { + p = "C --> S:" + } + return p +} diff --git a/log/stdlog.go b/log/stdlog.go index 65ae6e1..2ac2430 100644 --- a/log/stdlog.go +++ b/log/stdlog.go @@ -10,9 +10,6 @@ import ( "log" ) -// Level is a type wrapper for an int -type Level int - // Stdlog is the default logger that satisfies the Logger interface type Stdlog struct { l Level @@ -22,17 +19,6 @@ type Stdlog struct { debug *log.Logger } -const ( - // LevelError is the Level for only ERROR log messages - LevelError Level = iota - // LevelWarn is the Level for WARN and higher log messages - LevelWarn - // LevelInfo is the Level for INFO and higher log messages - LevelInfo - // LevelDebug is the Level for DEBUG and higher log messages - LevelDebug -) - // CallDepth is the call depth value for the log.Logger's Output method // This defaults to 2 and is only here for better readablity of the code const CallDepth = 2 @@ -80,12 +66,3 @@ func (l *Stdlog) Errorf(lo Log) { _ = l.err.Output(CallDepth, fmt.Sprintf(f, lo.Messages...)) } } - -// directionPrefix will return a prefix string depending on the Direction. -func (l Log) directionPrefix() string { - p := "C <-- S:" - if l.Direction == DirClientToServer { - p = "C --> S:" - } - return p -}