github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/worker/httpserver/logging.go (about) 1 // Copyright 2018 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package httpserver 5 6 import "github.com/juju/loggo" 7 8 // loggoWrapper is an io.Writer() that forwards the messages to a loggo.Logger. 9 // Unfortunately http takes a concrete stdlib log.Logger struct, and not an 10 // interface, so we can't just proxy all of the log levels without inspecting 11 // the string content. For now, we just want to get the messages into the log 12 // file. 13 type loggoWrapper struct { 14 logger loggo.Logger 15 level loggo.Level 16 } 17 18 func (w *loggoWrapper) Write(content []byte) (int, error) { 19 w.logger.Logf(w.level, "%s", string(content)) 20 return len(content), nil 21 }