MM-14574 Intercept log messages from local image proxy (#10668)

* MM-14574 Switch willnorris/imageproxy to fork

* MM-14574 Intercept log messages from local image proxy

* Revert "MM-14574 Switch willnorris/imageproxy to fork"

This reverts commit 046ab5c4216a5c6fee5bf8e2e0cceb1afffa6747.

* Update willnorris/imageproxy
Этот коммит содержится в:
Harrison Healey
2019-04-24 11:55:37 -04:00
коммит произвёл GitHub
родитель 7c7ff93d97
Коммит cbcfef25e5
11 изменённых файлов: 75 добавлений и 19 удалений

Просмотреть файл

@@ -32,7 +32,7 @@ func makeTestAtmosCamoProxy() *ImageProxy {
},
}
return MakeImageProxy(configService, httpservice.MakeHTTPService(configService))
return MakeImageProxy(configService, httpservice.MakeHTTPService(configService), nil)
}
func TestAtmosCamoBackend_GetImage(t *testing.T) {

Просмотреть файл

@@ -9,6 +9,7 @@ import (
"net/http"
"sync"
"github.com/mattermost/mattermost-server/mlog"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/services/configservice"
"github.com/mattermost/mattermost-server/services/httpservice"
@@ -24,6 +25,8 @@ type ImageProxy struct {
HTTPService httpservice.HTTPService
Logger *mlog.Logger
lock sync.RWMutex
backend ImageProxyBackend
}
@@ -45,10 +48,11 @@ type ImageProxyBackend interface {
GetUnproxiedImageURL(proxiedURL string) string
}
func MakeImageProxy(configService configservice.ConfigService, httpService httpservice.HTTPService) *ImageProxy {
func MakeImageProxy(configService configservice.ConfigService, httpService httpservice.HTTPService, logger *mlog.Logger) *ImageProxy {
proxy := &ImageProxy{
ConfigService: configService,
HTTPService: httpService,
Logger: logger,
}
proxy.configListenerId = proxy.ConfigService.AddConfigListener(proxy.OnConfigChange)

Просмотреть файл

@@ -43,6 +43,15 @@ type LocalBackend struct {
func makeLocalBackend(proxy *ImageProxy) *LocalBackend {
impl := imageproxy.NewProxy(proxy.HTTPService.MakeTransport(false), nil)
if proxy.Logger != nil {
logger, err := proxy.Logger.StdLogAt(mlog.LevelDebug, mlog.String("image_proxy", "local"))
if err != nil {
mlog.Error("Failed to initialize logger for image proxy", mlog.Err(err))
}
impl.Logger = logger
}
baseURL, err := url.Parse(*proxy.ConfigService.Config().ServiceSettings.SiteURL)
if err != nil {
mlog.Error("Failed to set base URL for image proxy. Relative image links may not work.", mlog.Err(err))

Просмотреть файл

@@ -31,7 +31,7 @@ func makeTestLocalProxy() *ImageProxy {
},
}
return MakeImageProxy(configService, httpservice.MakeHTTPService(configService))
return MakeImageProxy(configService, httpservice.MakeHTTPService(configService), nil)
}
func TestLocalBackend_GetImage(t *testing.T) {