commit 4256050bc28876a170377e143623f7eb1f5b967e Author: lif Date: Tue Apr 21 08:44:39 2026 +0100 initial diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..804b477 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM golang:alpine3.22 AS prep-image + +COPY . . +RUN CGO_ENABLED=0 GOOS=linux go build -o /logfly + +FROM scratch + +COPY --from=prep-image /logfly /logfly + +CMD ["/logfly"] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..de27a7f --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +docker-build: + docker build -t liffsh/logfling:latest --progress=plain ./ +docker-run: + docker run -e LOG_TYPE=json -v /var/run/docker.sock:/var/run/docker.sock liffsh/logfling:latest diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..871e2cb --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module git.lif.sh/lif/logfling + +go 1.25.1 diff --git a/main.go b/main.go new file mode 100644 index 0000000..b8a002f --- /dev/null +++ b/main.go @@ -0,0 +1,23 @@ +package main + +import ( + "log/slog" + "os" + "time" +) + +func main() { + logtype := os.Getenv("LOG_TYPE") + logger := slog.New(slog.NewTextHandler(os.Stdout, nil)) + if logtype == "json" { + logger = slog.New(slog.NewJSONHandler(os.Stdout, nil)) + } + logger.Info("Hello world!") + + ticker := time.NewTicker(1 * time.Second) + defer ticker.Stop() + + for _ = range ticker.C { + logger.Info("Ticking") + } +}