Audit package primer¶
The audit
package is responsible for initialising and providing a configured zap.Logger
to other packages.
Overview¶
During application startup, the logger configuration is loaded from config.GlobalConfig
. When audit.Init()
is called, an Auditor
instance containing the configured zap.Logger
is returned. This Auditor
is then propagated through middleware to various handler functions.
The audit package is initialised in main.go
as follows:
Go | |
---|---|
Propagation through middleware and handlers¶
The initialised Auditor
is passed to the middleware.DefineRoutes
function that sets up all application routes.
Go | |
---|---|
Handlers that require the configured zap.Logger
are wrapped using WrapWithAuditor
, providing each handler with the Auditor
instance.
Go | |
---|---|