fix: aws fixed logger level to debug
This commit is contained in:
parent
b4d8317e93
commit
fe8cc087c0
@ -40,7 +40,11 @@ ARG BINARYNAME="poller"
|
||||
|
||||
COPY . .
|
||||
# RUN make build-$BINARYNAME GOARCH=$TARGETARCH GOOS=$(echo $BUILDPLATFORM | cut -d'/' -f1) LDFLAGS='-extldflags="-static"'
|
||||
RUN make build-$BINARYNAME GOARCH=$TARGETARCH GOOS=$(echo $BUILDPLATFORM | cut -d'/' -f1) GOBUILDFLAGS="-a -tags netgo -installsuffix netgo"
|
||||
RUN make build-$BINARYNAME \
|
||||
GOARCH=$TARGETARCH \
|
||||
GOOS=$(echo $BUILDPLATFORM | cut -d'/' -f1) \
|
||||
GOBUILDFLAGS="-a -tags netgo -installsuffix netgo" \
|
||||
LDFLAGS="-w -s -d"
|
||||
|
||||
FROM scratch
|
||||
|
||||
|
6
Makefile
6
Makefile
@ -3,9 +3,9 @@
|
||||
|
||||
GOARCH=amd64
|
||||
# GOARCH=arm
|
||||
GOOS=linux
|
||||
# GOOS=darwin
|
||||
LDFLAGS=-w -s -d
|
||||
GOOS=darwin
|
||||
# GOOS=linux
|
||||
LDFLAGS=-w -s
|
||||
GOBUILDFLAGS=
|
||||
DOCKER_BUILDKIT=1
|
||||
CGO_ENABLED=0
|
||||
|
@ -42,7 +42,7 @@ func NewWeatherPoller(log *logger.WeatherLogger, remote web.ListenAddr, lat, lon
|
||||
//Poll retrieve weather information
|
||||
func (w *weatherPoller) Poll() io.ReadCloser {
|
||||
r, err := w.client.Get(w.endpoint.String())
|
||||
w.logger.Debug("HTTP poll to openweathermap",
|
||||
w.logger.Info("HTTP poll to openweathermap",
|
||||
zap.Int("http.response.status_code", r.StatusCode),
|
||||
zap.Int("http.response.body.bytes", int(r.ContentLength)),
|
||||
)
|
||||
|
@ -58,20 +58,20 @@ func NewS3Storage(log *logger.WeatherLogger, config *WeatherS3StorageConfig, buc
|
||||
|
||||
consolidateConfig = aws.Config{
|
||||
Endpoint: &customConfig.Default.EndpointURL,
|
||||
DisableSSL: aws.Bool(true),
|
||||
LogLevel: aws.LogLevel(aws.LogDebug),
|
||||
S3ForcePathStyle: aws.Bool(true),
|
||||
}
|
||||
} else {
|
||||
consolidateConfig = aws.Config{
|
||||
Endpoint: &config.EndpointURL,
|
||||
Credentials: credentials.NewStaticCredentials(config.AwsAccessKeyID, config.AwsSecretAccessKey, ""),
|
||||
Region: &config.Region,
|
||||
}
|
||||
}
|
||||
|
||||
consolidateConfig.MergeIn(&aws.Config{
|
||||
DisableSSL: aws.Bool(true),
|
||||
LogLevel: aws.LogLevel(aws.LogDebug),
|
||||
LogLevel: aws.LogLevel(log.GetAwsLevel()),
|
||||
S3ForcePathStyle: aws.Bool(true),
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
s, err := session.NewSessionWithOptions(session.Options{
|
||||
SharedConfigState: session.SharedConfigEnable,
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"go.elastic.co/apm/module/apmzap"
|
||||
"go.elastic.co/ecszap"
|
||||
"go.uber.org/zap"
|
||||
@ -152,3 +153,13 @@ func (wl *WeatherLogger) handleError(err error) {
|
||||
wl.Logger.Fatal("Logger error", zap.Error(err))
|
||||
}
|
||||
}
|
||||
|
||||
//GetAwsLevelnconvert log zapcore.Level to aws.LogLevelType
|
||||
func (wl *WeatherLogger) GetAwsLevel() aws.LogLevelType {
|
||||
switch wl.Level.Level() {
|
||||
case zapcore.DebugLevel:
|
||||
return aws.LogDebug
|
||||
default:
|
||||
return aws.LogOff
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user