github.com/matrixorigin/matrixone@v1.2.0/pkg/logutil/adapt_s3.go (about) 1 // Copyright 2022 Matrix Origin 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package logutil 16 17 import ( 18 "fmt" 19 20 "github.com/aws/smithy-go/logging" 21 "github.com/matrixorigin/matrixone/pkg/defines" 22 "go.uber.org/zap" 23 ) 24 25 func GetS3Logger() logging.Logger { 26 logger := GetSkip1Logger().Named(defines.SharedFileServiceName) 27 return &S3Logger{ 28 Logger: logger, 29 } 30 } 31 32 var _ logging.Logger = (*S3Logger)(nil) 33 34 type S3Logger struct { 35 *zap.Logger 36 } 37 38 func (logger *S3Logger) Logf(classification logging.Classification, format string, v ...any) { 39 msg := fmt.Sprintf(format, v...) 40 switch classification { 41 case logging.Warn: 42 logger.Warn(msg) 43 case logging.Debug: 44 logger.Debug(msg) 45 default: 46 logger.Info(msg) 47 } 48 }