Commit 1469f25bfc7cccaef5cecb97d323de874cc5df44

Authored by Marko Tikvić
1 parent 2726b56833
Exists in master

added utility for easier logging

Showing 1 changed file with 11 additions and 0 deletions   Show diff stats
middleware/middleware.go
... ... @@ -61,6 +61,17 @@ func SetLogger(logger *gologger.Logger) {
61 61 httpLogger = logger
62 62 }
63 63  
  64 +func StartLogging(filename, dir string) (err error) {
  65 + if httpLogger, err = gologger.New(filename, dir, gologger.MaxLogSize1MB); err != nil {
  66 + return err
  67 + }
  68 + return nil
  69 +}
  70 +
  71 +func CloseLogger() {
  72 + httpLogger.Close()
  73 +}
  74 +
64 75 // LogHTTP ...
65 76 func LogHTTP(h http.HandlerFunc) http.HandlerFunc {
66 77 return func(w http.ResponseWriter, req *http.Request) {
... ...