fix: aws fixed logger level to debug

This commit is contained in:
RouxAntoine 2021-03-12 02:04:54 +01:00
parent b4d8317e93
commit fe8cc087c0
Signed by: antoine
GPG Key ID: 098FB66FC0475E70
5 changed files with 30 additions and 15 deletions

View File

@ -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

View File

@ -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

View File

@ -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)),
)

View File

@ -57,22 +57,22 @@ func NewS3Storage(log *logger.WeatherLogger, config *WeatherS3StorageConfig, buc
s3.handleError(err)
consolidateConfig = aws.Config{
Endpoint: &customConfig.Default.EndpointURL,
DisableSSL: aws.Bool(true),
LogLevel: aws.LogLevel(aws.LogDebug),
S3ForcePathStyle: aws.Bool(true),
Endpoint: &customConfig.Default.EndpointURL,
}
} else {
consolidateConfig = aws.Config{
Endpoint: &config.EndpointURL,
Credentials: credentials.NewStaticCredentials(config.AwsAccessKeyID, config.AwsSecretAccessKey, ""),
Region: &config.Region,
DisableSSL: aws.Bool(true),
LogLevel: aws.LogLevel(aws.LogDebug),
S3ForcePathStyle: aws.Bool(true),
Endpoint: &config.EndpointURL,
Credentials: credentials.NewStaticCredentials(config.AwsAccessKeyID, config.AwsSecretAccessKey, ""),
Region: &config.Region,
}
}
consolidateConfig.MergeIn(&aws.Config{
DisableSSL: aws.Bool(true),
LogLevel: aws.LogLevel(log.GetAwsLevel()),
S3ForcePathStyle: aws.Bool(true),
})
s, err := session.NewSessionWithOptions(session.Options{
SharedConfigState: session.SharedConfigEnable,
Config: consolidateConfig,

View File

@ -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
}
}