Added a basic homepage
This commit is contained in:
parent
d40640a648
commit
12fd3c04ca
113 changed files with 414 additions and 506 deletions
27
internal/log/log.go
Normal file
27
internal/log/log.go
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
package log
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/camzawacki/personal-site/internal/context"
|
||||
)
|
||||
|
||||
// Set sets a logger in the context.
|
||||
func Set(ctx echo.Context, logger *slog.Logger) {
|
||||
ctx.Set(context.LoggerKey, logger)
|
||||
}
|
||||
|
||||
// Ctx returns the logger stored in context, or provides the default logger if one is not present.
|
||||
func Ctx(ctx echo.Context) *slog.Logger {
|
||||
if l, ok := ctx.Get(context.LoggerKey).(*slog.Logger); ok {
|
||||
return l
|
||||
}
|
||||
|
||||
return Default()
|
||||
}
|
||||
|
||||
// Default returns the default logger.
|
||||
func Default() *slog.Logger {
|
||||
return slog.Default()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue