Lint fixes

This commit is contained in:
Paul Tötterman
2020-10-19 13:40:52 +03:00
parent 3cec19ee62
commit 3d924a016b
65 changed files with 884 additions and 1083 deletions

View File

@@ -1,10 +1,11 @@
package logger
import (
"github.com/mattn/go-colorable"
"gopkg.in/natefinch/lumberjack.v2"
"io"
"os"
"github.com/mattn/go-colorable"
"gopkg.in/natefinch/lumberjack.v2"
)
type CompositeMultiHandler struct {
@@ -19,8 +20,8 @@ func NewCompositeMultiHandler() (*CompositeMultiHandler, LogHandler) {
cw := &CompositeMultiHandler{}
return cw, cw
}
func (h *CompositeMultiHandler) Log(r *Record) (err error) {
func (h *CompositeMultiHandler) Log(r *Record) (err error) {
var handler LogHandler
switch r.Level {
@@ -78,7 +79,7 @@ func (h *CompositeMultiHandler) SetHandler(handler LogHandler, replace bool, lev
}
}
// For the multi handler set the handler, using the LogOptions defined
// For the multi handler set the handler, using the LogOptions defined.
func (h *CompositeMultiHandler) SetHandlers(handler LogHandler, options *LogOptions) {
if len(options.Levels) == 0 {
options.Levels = LvlAllList
@@ -88,8 +89,8 @@ func (h *CompositeMultiHandler) SetHandlers(handler LogHandler, options *LogOpti
for _, lvl := range options.Levels {
h.SetHandler(handler, options.ReplaceExistingHandler, lvl)
}
}
func (h *CompositeMultiHandler) SetJson(writer io.Writer, options *LogOptions) {
handler := CallerFileHandler(StreamHandler(writer, JsonFormatEx(
options.GetBoolDefault("pretty", false),
@@ -101,12 +102,12 @@ func (h *CompositeMultiHandler) SetJson(writer io.Writer, options *LogOptions) {
h.SetHandlers(handler, options)
}
// Use built in rolling function
// Use built in rolling function.
func (h *CompositeMultiHandler) SetJsonFile(filePath string, options *LogOptions) {
writer := &lumberjack.Logger{
Filename: filePath,
MaxSize: options.GetIntDefault("maxSizeMB", 1024), // megabytes
MaxAge: options.GetIntDefault("maxAgeDays", 7), //days
MaxAge: options.GetIntDefault("maxAgeDays", 7), // days
MaxBackups: options.GetIntDefault("maxBackups", 7),
Compress: options.GetBoolDefault("compress", true),
}
@@ -141,12 +142,12 @@ func (h *CompositeMultiHandler) SetTerminal(writer io.Writer, options *LogOption
h.SetHandlers(handler, options)
}
// Use built in rolling function
// Use built in rolling function.
func (h *CompositeMultiHandler) SetTerminalFile(filePath string, options *LogOptions) {
writer := &lumberjack.Logger{
Filename: filePath,
MaxSize: options.GetIntDefault("maxSizeMB", 1024), // megabytes
MaxAge: options.GetIntDefault("maxAgeDays", 7), //days
MaxAge: options.GetIntDefault("maxAgeDays", 7), // days
MaxBackups: options.GetIntDefault("maxBackups", 7),
Compress: options.GetBoolDefault("compress", true),
}