logsupport

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
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.

View Source
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

func LogSmithyError(err error) (service, operation, code, message string, fault smithy.ErrorFault)

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

func SetUpGlobalLogger(ctx context.Context) func()

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

func SetUpLogger(ctx context.Context, logger *log.Logger) func()

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL