chore: use json logger
This commit is contained in:
@@ -23,13 +23,19 @@ func main() {
|
|||||||
cancle()
|
cancle()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
slog.SetLogLoggerLevel(slog.LevelDebug)
|
slog.SetDefault(slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelDebug})))
|
||||||
|
|
||||||
cfg, err := config.Read(ctx)
|
cfg, err := config.Read(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("could not read configuaration", "err", err)
|
slog.Error("could not read configuaration", "err", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
slog.SetDefault(
|
||||||
|
slog.New(
|
||||||
|
slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{Level: cfg.LogLevel}),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
err = server.Start(ctx, cfg)
|
err = server.Start(ctx, cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("error while serving", "err", err)
|
slog.Error("error while serving", "err", err)
|
||||||
|
|||||||
@@ -57,12 +57,17 @@ func PathFromUID(uid string) (string, error) {
|
|||||||
func SourceSet(src string) string {
|
func SourceSet(src string) string {
|
||||||
sb := strings.Builder{}
|
sb := strings.Builder{}
|
||||||
|
|
||||||
for i := range 19 {
|
const steps = 300
|
||||||
sb.WriteString(fmt.Sprintf("%s?w=%d %dw, ", src, 100*(i+1), 100*(i+1)))
|
const max = 1500
|
||||||
}
|
|
||||||
|
|
||||||
i := 20
|
|
||||||
sb.WriteString(fmt.Sprintf("%s?w=%d %dw", src, 100*(i+1), 100*(i+1)))
|
|
||||||
|
|
||||||
|
i := 1
|
||||||
|
for {
|
||||||
|
width := i * steps
|
||||||
|
sb.WriteString(fmt.Sprintf("%s?w=%d %dw, ", src, width, width))
|
||||||
|
if width >= max {
|
||||||
return sb.String()
|
return sb.String()
|
||||||
|
}
|
||||||
|
sb.WriteRune(',')
|
||||||
|
i++
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package config
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"log/slog"
|
||||||
|
|
||||||
"github.com/sethvargo/go-envconfig"
|
"github.com/sethvargo/go-envconfig"
|
||||||
)
|
)
|
||||||
@@ -11,6 +12,8 @@ type Cfg struct {
|
|||||||
Cache *ValkeyConfig `env:", prefix=CACHE_"`
|
Cache *ValkeyConfig `env:", prefix=CACHE_"`
|
||||||
Image *ImageConfig `env:", prefix=IMAGE_"`
|
Image *ImageConfig `env:", prefix=IMAGE_"`
|
||||||
Tracking *UmamiConfig `env:", prefix=TRACKING_"`
|
Tracking *UmamiConfig `env:", prefix=TRACKING_"`
|
||||||
|
|
||||||
|
LogLevel slog.Level `env:"LOG_LEVEL, default=DEBUG"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type WebdavConfig struct {
|
type WebdavConfig struct {
|
||||||
|
|||||||
@@ -22,13 +22,14 @@ templ Base(cfg config.Cfg, title string) {
|
|||||||
<header
|
<header
|
||||||
class="fixed z-50 mix-blend-difference p-1 w-full flex justify-between items-start"
|
class="fixed z-50 mix-blend-difference p-1 w-full flex justify-between items-start"
|
||||||
>
|
>
|
||||||
<a class="text-white text-2xl" href={ translate.Path(ctx, "") }>schreifuchs.ch</a>
|
<a class="text-white text-2xl" href={ translate.Path(ctx, "") } preload="mouseover" preload-images="true">schreifuchs.ch</a>
|
||||||
<nav class="flex gap-2 p-2">
|
<nav class="flex gap-2 p-2">
|
||||||
for _, lang := range translate.SupportedLanguages(ctx) {
|
for _, lang := range translate.SupportedLanguages(ctx) {
|
||||||
<a
|
<a
|
||||||
href={ translate.PathForLang(ctx, lang, strings.Split(templer.Path(ctx), "/")...) }
|
href={ translate.PathForLang(ctx, lang, strings.Split(templer.Path(ctx), "/")...) }
|
||||||
hreflang={ lang }
|
hreflang={ lang }
|
||||||
data-no-translate
|
data-no-translate
|
||||||
|
preload="mouseover"
|
||||||
class="text-white hover:underline uppercase"
|
class="text-white hover:underline uppercase"
|
||||||
>
|
>
|
||||||
{ lang }
|
{ lang }
|
||||||
|
|||||||
@@ -9,7 +9,12 @@ import (
|
|||||||
templ Home(pages []page.PageHeader) {
|
templ Home(pages []page.PageHeader) {
|
||||||
for _, page := range pages {
|
for _, page := range pages {
|
||||||
@components.ImageTile("/images/" + page.CoverImageUID) {
|
@components.ImageTile("/images/" + page.CoverImageUID) {
|
||||||
<a class="flex items-center justify-center h-full " href={ translate.Path(ctx, "/"+page.UID) } preload="mouseover">
|
<a
|
||||||
|
class="flex items-center justify-center h-full "
|
||||||
|
href={ translate.Path(ctx, "/"+page.UID) }
|
||||||
|
preload="mouseover"
|
||||||
|
preload-images="true"
|
||||||
|
>
|
||||||
<h2
|
<h2
|
||||||
class="text-3xl font-bold text-white hover:underline text-shadow-lg"
|
class="text-3xl font-bold text-white hover:underline text-shadow-lg"
|
||||||
>
|
>
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user