This commit is contained in:
lif
2026-04-21 08:44:39 +01:00
commit 4256050bc2
5 changed files with 40 additions and 0 deletions

0
.gitignore vendored Normal file
View File

10
Dockerfile Normal file
View File

@@ -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"]

4
Makefile Normal file
View File

@@ -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

3
go.mod Normal file
View File

@@ -0,0 +1,3 @@
module git.lif.sh/lif/logfling
go 1.25.1

23
main.go Normal file
View File

@@ -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")
}
}