diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/config.go | 1 | ||||
-rw-r--r-- | utils/log.go | 33 |
2 files changed, 34 insertions, 0 deletions
diff --git a/utils/config.go b/utils/config.go index 86fe7c062..9700f44e0 100644 --- a/utils/config.go +++ b/utils/config.go @@ -249,6 +249,7 @@ func getClientConfig(c *model.Config) map[string]string { props["DefaultClientLocale"] = *c.LocalizationSettings.DefaultClientLocale props["AvailableLocales"] = *c.LocalizationSettings.AvailableLocales + props["SQLDriverName"] = c.SqlSettings.DriverName if IsLicensed { if *License.Features.CustomBrand { diff --git a/utils/log.go b/utils/log.go new file mode 100644 index 000000000..360c785d0 --- /dev/null +++ b/utils/log.go @@ -0,0 +1,33 @@ +// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package utils + +import ( + "bytes" + "io" + "io/ioutil" + + l4g "github.com/alecthomas/log4go" +) + +// DebugReader logs the content of the io.Reader and returns a new io.Reader +// with the same content as the received io.Reader. +// If you pass reader by reference, it won't be re-created unless the loglevel +// includes Debug. +// If an error is returned, the reader is consumed an cannot be read again. +func DebugReader(reader io.Reader, message string) (io.Reader, error) { + var err error + l4g.Debug(func() string { + content, err := ioutil.ReadAll(reader) + if err != nil { + return "" + } + + reader = bytes.NewReader(content) + + return message + string(content) + }) + + return reader, err +} |