m: add TODO to figure out wtf to do about m.Log

This commit is contained in:
Brian Picciano 2018-07-19 19:37:05 +00:00
parent 8368d0881b
commit 0a96d5c61e

12
m/m.go
View File

@ -11,6 +11,16 @@ import (
"github.com/mediocregopher/mediocre-go-lib/mlog"
)
// TODO this isn't going to work. At some point there will be something like
// mhttp which will have some glue code for it in here, but then something
// within it which logs (like the http server), and then there'll be an import
// cycle.
//
// Ultimately it might be worthwhile to make Logger be a field on Cfg, that
// really seems like the only other place where code like this makes sense to
// go. But then that's greatly expanding the purview of Cfg, which is
// unfortunate....
// Log returns a Logger which will automatically include with the log extra
// contextual information based on the Cfg and the given KVs
//
@ -18,7 +28,7 @@ import (
func Log(cfg *mcfg.Cfg, kvs ...mlog.KVer) *mlog.Logger {
fn := cfg.FullName()
l := mlog.DefaultLogger.WithWriteFn(func(w io.Writer, msg mlog.Message) error {
msg.Msg = fn + " " + msg.Msg
msg.Msg = "(" + fn + ") " + msg.Msg
return mlog.DefaultWriteFn(w, msg)
})
if len(kvs) > 0 {