From 1469f25bfc7cccaef5cecb97d323de874cc5df44 Mon Sep 17 00:00:00 2001 From: "marko.tikvic" Date: Tue, 26 Nov 2019 10:24:44 +0100 Subject: [PATCH] added utility for easier logging --- middleware/middleware.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/middleware/middleware.go b/middleware/middleware.go index ec547a8..5779f13 100644 --- a/middleware/middleware.go +++ b/middleware/middleware.go @@ -61,6 +61,17 @@ func SetLogger(logger *gologger.Logger) { httpLogger = logger } +func StartLogging(filename, dir string) (err error) { + if httpLogger, err = gologger.New(filename, dir, gologger.MaxLogSize1MB); err != nil { + return err + } + return nil +} + +func CloseLogger() { + httpLogger.Close() +} + // LogHTTP ... func LogHTTP(h http.HandlerFunc) http.HandlerFunc { return func(w http.ResponseWriter, req *http.Request) { -- 1.8.1.2