Documentation
¶
Index ¶
- Constants
- func LogSmithyError(err error) (service, operation, code, message string, fault smithy.ErrorFault)
- func LogSmithyErrorWithLogger(err error, logger *log.Logger) (service, operation, code, message string, fault smithy.ErrorFault)
- func SetUpGlobalLogger(ctx context.Context) func()
- func SetUpLogger(ctx context.Context, logger *log.Logger) func()
- func SetUpZeroLogGlobalLevel()
Constants ¶
const RecommendedDebugLogFlag = log.Ldate | log.Lmicroseconds | log.LUTC | log.Llongfile | log.Lmsgprefix
RecommendedDebugLogFlag is the flag passed to log.SetFlags by SetUpLogger if configsupport.IsDebug is true.
const RecommendedLogFlag = RecommendedDebugLogFlag | log.Lshortfile
RecommendedLogFlag is the flag passed to log.SetFlags by SetUpLogger if configsupport.IsDebug is false.
Variables ¶
This section is empty.
Functions ¶
func LogSmithyError ¶
LogSmithyError checks that the given error is of type smithy.OperationError and/or smithy.APIError and logs the fields.
Returns in this order: service, operation, code, message, and fault. See smithyerrors.Parse if you only need to parse the error without any logging.
func LogSmithyErrorWithLogger ¶
func LogSmithyErrorWithLogger(err error, logger *log.Logger) (service, operation, code, message string, fault smithy.ErrorFault)
LogSmithyErrorWithLogger is a variant of LogSmithyError that allows specifying a log.Logger to use.
func SetUpGlobalLogger ¶
SetUpGlobalLogger sets up log.Default with flags set to RecommendedLogFlag and prefix set to the AwsRequestID from lambdacontext.FromContext.
A function is returned that should be deferred upon to reset the log flags and prefix back to the original values. Use SetUpLogger if you wish to modify a specific log.Logger.
Usage
// notice the double ()() to make sure SetUpGlobalLogger is run first, then its returned function is deferred. defer logsupport.SetUpGlobalLogger())
func SetUpLogger ¶
SetUpLogger is a variant of SetUpGlobalLogger that targets a specific log.Logger.
func SetUpZeroLogGlobalLevel ¶
func SetUpZeroLogGlobalLevel()
SetUpZeroLogGlobalLevel sets zerolog.SetGlobalLevel according to available environment variables.
If ZEROLOG_GLOBAL_LEVEL is parsable with zerolog.ParseLevel then that value will be used. If configsupport.IsDebug is true then the level will be set to Debug. Otherwise, Info will be used as the default level.
Types ¶
This section is empty.