Documentation ¶
Overview ¶
Package logger configures slog for AWS CloudWatch
Index ¶
- Constants
- func New(opts ...Option) *slog.Logger
- func NewJSONHandler(opts ...Option) slog.Handler
- type Attributes
- type Option
- func WithLogLevel(level slog.Leveler) Option
- func WithLogLevel7() Option
- func WithLogLevelForMod(mods map[string]slog.Level) Option
- func WithLogLevelForModFromEnv() Option
- func WithLogLevelFromEnv() Option
- func WithLogLevelShorten() Option
- func WithSource() Option
- func WithSourceFileName() Option
- func WithSourceShorten() Option
- func WithWriter(w io.Writer) Option
- func WithoutTimestamp() Option
Constants ¶
View Source
const ( // EMERGENCY // system is unusable, panic execution of current routine/application, // it is notpossible to gracefully terminate it. EMERGENCY = slog.Level(100) // CRITICAL // system is failed, response actions must be taken immediately, // the application is not able to execute correctly but still // able to gracefully exit. CRITICAL = slog.Level(50) // ERROR // system is failed, unable to recover from error. // The failure do not have global catastrophic impacts but // local functionality is impaired, incorrect result is returned. ERROR = slog.LevelError // WARN // system is failed, unable to recover, degraded functionality. // The failure is ignored and application still capable to deliver // incomplete but correct results. WARN = slog.LevelWarn // NOTICE // system is failed, error is recovered, no impact NOTICE = slog.Level(2) // INFO // output informative status about system INFO = slog.LevelInfo // DEBUG // output debug status about system DEBUG = slog.LevelDebug )
Variables ¶
This section is empty.
Functions ¶
func NewJSONHandler ¶ added in v3.1.0
Create's new handler
Types ¶
type Attributes ¶ added in v3.1.0
combinator of attribute formatting
type Option ¶
type Option func(*opts)
Config options for slog
func WithLogLevel7 ¶ added in v3.1.0
func WithLogLevel7() Option
WithLevel7 enables from DEBUG to EMERGENCY levels
func WithLogLevelForMod ¶ added in v3.1.0
Config Log Levels per module
func WithLogLevelForModFromEnv ¶ added in v3.1.0
func WithLogLevelForModFromEnv() Option
Config Log Levels per module from env variables CONFIG_LOG_LEVEL_{NAME}
CONFIG_LOG_LEVEL_DEBUG=github.com/fogfish/logger/*:github.com/your/app
func WithLogLevelFromEnv ¶
func WithLogLevelFromEnv() Option
Config Log Level from env CONFIG_LOG_LEVEL, default INFO
func WithLogLevelShorten ¶ added in v3.1.0
func WithLogLevelShorten() Option
Config Log Level to be 3 letters only
func WithSourceFileName ¶ added in v3.1.0
func WithSourceFileName() Option
Logs file name of the source file
func WithSourceShorten ¶ added in v3.1.0
func WithSourceShorten() Option
Shorten Source file to letters only
func WithoutTimestamp ¶ added in v3.1.0
func WithoutTimestamp() Option
Exclude timestamp, required by CloudWatch
Click to show internal directories.
Click to hide internal directories.