From bc4a337048a82c0ea9cfde24a1b583cff78751c3 Mon Sep 17 00:00:00 2001
From: zhangmeng <775834166@qq.com>
Date: 星期一, 23 十二月 2019 11:04:30 +0800
Subject: [PATCH] update

---
 logo/logo.go |   76 +++++++++++++++++---------------------
 1 files changed, 34 insertions(+), 42 deletions(-)

diff --git a/logo/logo.go b/logo/logo.go
index 0288a56..9209791 100644
--- a/logo/logo.go
+++ b/logo/logo.go
@@ -1,89 +1,81 @@
 package logo
 
 import (
-	"fmt"
-
-	"basic.com/valib/logger.git"
+	"github.com/amoghe/distillog"
+	"github.com/natefinch/lumberjack"
 )
 
-var console = false
+var loggers []distillog.Logger
 
-// Config config
 func Config(name string, size, backup, age int) {
-	logger.Config(name, logger.DebugLevel)
+	l := &lumberjack.Logger{
+		Filename:   name,
+		MaxSize:    size, // megabytes
+		MaxBackups: backup,
+		MaxAge:     age, // days
+	}
 
+	logger := distillog.NewStreamLogger("file", l)
+	loggers = append(loggers, logger)
+
+	distillog.SetOutput(l)
 }
 
-// ShowConsole show
 func ShowConsole() {
-	console = true
+	l := distillog.NewStdoutLogger("console")
+	loggers = append(loggers, l)
 }
 
-// Debugf debug
 func Debugf(f string, v ...interface{}) {
-	logger.Debug(f, v)
-	if console {
-		fmt.Printf(f, v...)
+	for _, l := range loggers {
+		l.Debugf(f, v...)
 	}
 }
 
-// Debugln ln
 func Debugln(v ...interface{}) {
-	logger.Debug(v)
-	if console {
-		fmt.Println(v...)
+	for _, l := range loggers {
+		l.Debugln(v)
 	}
 }
 
-// Infof fmt
 func Infof(f string, v ...interface{}) {
-	logger.Info(f, v)
-	if console {
-		fmt.Printf(f, v...)
+	for _, l := range loggers {
+		l.Infof(f, v...)
 	}
 }
 
-// Infoln ln
 func Infoln(v ...interface{}) {
-	logger.Info(v)
-	if console {
-		fmt.Println(v...)
+	for _, l := range loggers {
+		l.Infoln(v)
 	}
 }
 
-// Warningf fmt
 func Warningf(f string, v ...interface{}) {
-	logger.Warn(f, v)
-	if console {
-		fmt.Printf(f, v...)
+	for _, l := range loggers {
+		l.Warningf(f, v...)
 	}
 }
 
-// Warningln ln
 func Warningln(v ...interface{}) {
-	logger.Warn(v)
-	if console {
-		fmt.Println(v...)
+	for _, l := range loggers {
+		l.Warningln(v)
 	}
 }
 
-// Errorf fmt
 func Errorf(f string, v ...interface{}) {
-	logger.Error(f, v)
-	if console {
-		fmt.Printf(f, v...)
+	for _, l := range loggers {
+		l.Errorf(f, v...)
 	}
 }
 
-// Errorln ln
 func Errorln(v ...interface{}) {
-	logger.Error(v)
-	if console {
-		fmt.Println(v...)
+	for _, l := range loggers {
+		l.Errorln(v)
 	}
 }
 
-// Close close
 func Close() {
-
+	for _, l := range loggers {
+		l.Close()
+	}
 }

--
Gitblit v1.8.0