package example

import (
	"context"
	"fmt"
	"log/slog"

	"quantex.com/qfixdpl/src/app"
	googlechat "quantex.com/qfixdpl/src/client/notify/google"
	"quantex.com/qfixdpl/src/cmd"
	"quantex.com/qfixdpl/src/common/logger"
)

func LogsRunner(cfg app.Config) error {
	notify := googlechat.New(cfg.Notify.Google)
	logger.SetNotifier(notify)

	slog.Debug("This is a debug message with a tag", "tag", "debug")
	slog.Info("This is an info message with a tag", "tag", "info")
	slog.Error("This is an error message with a tag", "tag", "error")

	slog.Info("Press Ctrl-C to exit")

	fmt.Println("--------------------------------------------------")

	slog.Warn("This is a warn")

	slog.Info("Group example",
		slog.Group("user",
			slog.String("id", "1234"),
			slog.String("name", "Juan Pérez"),
		),
		slog.String("action", "session start"),
	)

	type contextKey string

	const loggerKey contextKey = "logger"

	ctx := context.WithValue(context.Background(), loggerKey, nil)

	slog.InfoContext(ctx, "Log with context",
		slog.String("user", "Juan Pérez"),
		slog.Int("id", 1234),
	)

	cmd.WaitForInterruptSignal(nil)

	return nil
}
